diff --git a/.eslintrc b/.eslintrc index 7f27860..8037689 100755 --- a/.eslintrc +++ b/.eslintrc @@ -19,6 +19,10 @@ "plugins": [ "prettier" ], + "ignorePatterns": [ + "**/*.json", + "**/*.json5" + ], "rules": { "prettier/prettier": [ 1, diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 2a1d465..14f71b9 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,4 +1,7 @@ -custom: ['https://commerce.coinbase.com/checkout/466d703a-fbd7-41c9-8366-9bdd3e240755'] +--- + +custom: + - https://commerce.coinbase.com/checkout/466d703a-fbd7-41c9-8366-9bdd3e240755 ko_fi: miraclx liberapay: miraclx patreon: miraclx diff --git a/.github/linters/.jscpd.json b/.github/linters/.jscpd.json new file mode 100644 index 0000000..640c211 --- /dev/null +++ b/.github/linters/.jscpd.json @@ -0,0 +1,10 @@ +{ + "threshold": 0, + "reporters": [ + "consoleFull" + ], + "ignore": [ + "**/.github/workflows/tests.yml" + ], + "absolute": true +} diff --git a/.github/workflows/ci-prep.sh b/.github/workflows/ci-prep.sh old mode 100644 new mode 100755 index 1718e0a..ef3d57f --- a/.github/workflows/ci-prep.sh +++ b/.github/workflows/ci-prep.sh @@ -1,10 +1,12 @@ +#!/usr/bin/env bash + RG_SRC="$(which rg)" rg() { - printf "rg: pattern: /$*/" > /dev/stderr + printf 'rg: pattern: %s' "/$*/" >/dev/stderr if $RG_SRC --fixed-strings --passthru "$@"; then - echo " (matched)" > /dev/stderr + echo " (matched)" >/dev/stderr else - echo " (failed to match)" > /dev/stderr + echo " (failed to match)" >/dev/stderr return 1 fi } @@ -16,7 +18,7 @@ freyr() { i=$($RG_SRC -n '.' .freyr_log | $RG_SRC --fixed-strings '[•] Embedding Metadata' | cut -d':' -f1) if [[ $i ]]; then echo "::group::[$attempts/3] View Download Status" - tail +$i .freyr_log + tail +"$i" .freyr_log echo "::endgroup::" fi } @@ -25,9 +27,9 @@ exec_retry() { cmd="$(cat)" && attempts=1 until eval "$cmd"; do echo "::endgroup::" - if (( attempts < 3 )); then + if ((attempts < 3)); then echo "::warning::[$attempts/3] Download failed, retrying.." - : $(( attempts += 1 )) + : $((attempts += 1)) else echo "::error::[$attempts/3] Download failed." return 1 @@ -36,7 +38,7 @@ exec_retry() { echo "::endgroup::" echo "::group::View Files" STAGE=$(realpath --relative-to=../.. .) && cd ../.. - tree -sh $STAGE + tree -sh "$STAGE" echo "::endgroup::" } @@ -45,5 +47,5 @@ validate() { res=$(<.freyr_log) for arg in "[•] Collation Complete" "$@"; do res=$(echo "$res" | rg "$arg") || return 1 - done > /dev/null + done >/dev/null } diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4b5765e..80c5568 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,3 +1,4 @@ +--- name: publish on: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 37b4bc0..d2672a7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,3 +1,4 @@ +--- name: tests on: @@ -238,3 +239,28 @@ jobs: - name: Test Docker Build run: docker build -t freyrcli/freyrjs . + + linter: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + with: + # Full git history is needed to get a proper list of changed files within `super-linter` + fetch-depth: 0 + + - name: Install Dependencies + run: npm ci + + - name: Lint Code Base + uses: github/super-linter@v4 + env: + VALIDATE_ALL_CODEBASE: false + DEFAULT_BRANCH: master + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + LINTER_RULES_PATH: / + JAVASCRIPT_ES_CONFIG_FILE: .eslintrc + JSCPD_CONFIG_FILE: .github/linters/.jscpd.json + VALIDATE_JAVASCRIPT_STANDARD: false diff --git a/Dockerfile b/Dockerfile index 7209d2c..db733c3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,7 @@ LABEL maintainer="Miraculous Owonubi " \ tag="alpine" # Install dependencies and clean cache +# hadolint ignore=DL3018 RUN apk add \ --no-cache \ git \ @@ -26,6 +27,7 @@ RUN mkdir /bins \ ENV PATH "/bins:$PATH" # Create freyr user and group +# hadolint ignore=DL4006 RUN addgroup -g 1000 freyr \ && adduser -DG freyr freyr \ && echo freyr:freyr | chpasswd diff --git a/LICENSE b/LICENSE index 0e52542..6ec7e67 100644 --- a/LICENSE +++ b/LICENSE @@ -1,176 +1,176 @@ Apache License Version 2.0, January 2004 - http://www.apache.org/licenses/ + http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS diff --git a/README.md b/README.md index baf1f72..285918a 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ macOS + Linux: [nvm](https://github.com/nvm-sh/nvm) recommended. - ``` bash + ```bash # install node with this nvm command # freyr works with a minimum of v12 $ nvm install --lts @@ -99,7 +99,9 @@
ffmpeg >= v0.9 + Download for your individual platforms here + - Windows + macOS: - Ensure to extract the `ffmpeg` binary from the compressed file, if it's in one. @@ -145,7 +147,7 @@ First start by ensuring all requirements listed above are satisfied. Thereafter, -
Or you can build from source - ``` bash + ```bash git clone https://github.com/miraclx/freyr-js.git freyr cd freyr ``` @@ -165,13 +167,13 @@ Image Size: [![Docker Image Size](https://img.shields.io/docker/image-size/freyr #### Usage (docker) -``` bash +```bash docker run -it --rm -v $PWD:/data freyrcli/freyrjs [options, arguments and queries...] ``` You can also create a handy alias to skip remembering that whole line everytime -``` bash +```bash alias freyr='docker run -it --rm -v $PWD:/data freyrcli/freyrjs' ``` @@ -186,7 +188,7 @@ alias freyr='docker run -it --rm -v $PWD:/data freyrcli/freyrjs' ### Usage -``` text +```text Usage: freyr [options] [query...] Usage: freyr [options] [subcommand] ``` @@ -201,7 +203,7 @@ Usage: freyr [options] [subcommand] *The `get` subcommand is implicit and default. -``` text +```text Usage: freyr [options] get [options] [query...] Usage: freyr [options] [query...] ``` @@ -209,7 +211,8 @@ Usage: freyr [options] [query...]
freyr get --help -``` console + +```console ____ / __/_______ __ _______ / /_/ ___/ _ \/ / / / ___/ @@ -294,6 +297,7 @@ Info: their respective folders. However, a m3u8 playlist file is generated in the base directory with the name of the playlist that lists the tracks ``` +
@@ -302,7 +306,8 @@ Info:
freyr spotify:track:5FNS5Vj69AhRGJWjhrAd01 -``` console + +```console ____ / __/_______ __ _______ / /_/ ___/ _ \/ / / / ___/ @@ -353,6 +358,7 @@ Checking directory permissions...[done] [•] Output bitrate: 320k =============================== ``` +
@@ -361,7 +367,8 @@ Checking directory permissions...[done]
freyr https://music.apple.com/us/album/im-sorry-im-not-sorry-ep/1491795443 -``` console + +```console ____ / __/_______ __ _______ / /_/ ___/ _ \/ / / / ___/ @@ -436,6 +443,7 @@ Checking directory permissions...[done] [•] Output bitrate: 320k =============================== ``` +
@@ -444,7 +452,8 @@ Checking directory permissions...[done]
freyr https://www.deezer.com/us/artist/14808825 -``` console + +```console ____ / __/_______ __ _______ / /_/ ___/ _ \/ / / / ___/ @@ -503,6 +512,7 @@ Checking directory permissions...[done] [•] Output bitrate: 320k =============================== ``` +
@@ -512,7 +522,7 @@ Checking directory permissions...[done] Queries can be collated to be processed at once. -``` bash +```bash freyr query1 query2 ... queryN ``` @@ -523,7 +533,7 @@ Queries should be on separate lines. Lines starting with a `#` are treated as comments and ignored. comments can also be inlined with everything following the `#` character ignored. -``` text +```text # ./queue.txt # Hailee Steinfeld @@ -534,7 +544,7 @@ https://open.spotify.com/track/7GCVboEDzfL3NKp1NrAgHR # (track) Wrong Direction https://open.spotify.com/album/3stadz88XVpHcXnVYMHc4J ``` -``` bash +```bash freyr -i ./queue.txt ``` @@ -582,7 +592,7 @@ Creating freyr-compatible queue output.
freyr urify https://open.spotify.com/album/2D23kwwoy2JpZVuJwzE42B --no-header --no-logo --no-tag -``` text +```text spotify:album:2D23kwwoy2JpZVuJwzE42B [+] Urify complete ``` @@ -592,7 +602,7 @@ spotify:album:2D23kwwoy2JpZVuJwzE42B
freyr urify -i queue_of_urls.txt -o queue_of_uris.txt --no-header --no-logo -``` text +```text [+] Urify complete Successfully written to [queue_of_uris.txt] ``` @@ -683,7 +693,7 @@ Defaults are in the [conf.json](https://github.com/miraclx/freyr-js/blob/master/
Example JSON -``` json +```json { "server": { "hostname": "localhost", @@ -752,7 +762,7 @@ An invalid `refreshToken`, when specified, would fallback to requesting account - `storefront`: \ - `developerToken`: \ -This library already includes a pre-defined developer token that should work at will. This developer token is the default token, extracted off the Apple Music website. While this developer token could expire over time, we'll try to update with the most recent developer token as time goes on. +This library already includes a predefined developer token that should work at will. This developer token is the default token, extracted off the Apple Music site. While this developer token could expire over time, we'll try to update with the most recent developer token as time goes on. To create a custom developer token, please refer to the Apple Music documentation on this topic. @@ -848,7 +858,7 @@ To preview filter rules specification, use the `filter` subcommand.
freyr filter title="all*good girls*hell",artist="*eilish",trackn="4..=5" --no-header --no-logo -``` text +```text [ { "query": "*", @@ -870,7 +880,7 @@ To preview filter rules specification, use the `filter` subcommand. | [Spotify](https://github.com/miraclx/freyr-js/blob/master/src/services/spotify.js) | ✔ | ✔ | ✔ | ✔ | `spotify:` | | [Apple Music](https://github.com/miraclx/freyr-js/blob/master/src/services/apple_music.js) | ✔ | ✔ | ✔ | ✔ | `apple_music:` | | [Deezer](https://github.com/miraclx/freyr-js/blob/master/src/services/deezer.js) | ✔ | ✔ | ✔ | ✔ | `deezer:` | -| Youtube Music (See [#6](https://github.com/miraclx/freyr-js/issues/6)) | ✗ | ✗ | ✗ | ✗ | ✗ | +| YouTube Music (See [#6](https://github.com/miraclx/freyr-js/issues/6)) | ✗ | ✗ | ✗ | ✗ | ✗ | | Tidal (See [#33](https://github.com/miraclx/freyr-js/issues/33)) | ✗ | ✗ | ✗ | ✗ | ✗ | ### Metadata Availability @@ -1031,14 +1041,14 @@ To preview filter rules specification, use the `filter` subcommand. Feel free to clone and use in adherance to the [license](#license). Pull requests are very much welcome. -``` bash +```bash git clone https://github.com/miraclx/freyr-js.git freyr cd freyr ``` - If using [NPM](https://github.com/npm/cli): - ``` bash + ```bash npm install # to have access to the freyr command globally @@ -1047,7 +1057,7 @@ cd freyr - If using [Yarn](https://github.com/yarnpkg/yarn): - ``` bash + ```bash yarn install # to have access to the freyr command globally @@ -1058,7 +1068,7 @@ cd freyr The default provided [Dockerfile](https://github.com/miraclx/freyr-js/raw/master/Dockerfile) builds minimal alpine images. Average build network usage is ~ 80 MB and disk usage is ~ 180 MB. -``` bash +```bash git clone https://github.com/miraclx/freyr-js.git freyr cd freyr docker build -t freyr-dev . @@ -1066,7 +1076,7 @@ docker build -t freyr-dev . Afterwards, you can drop into the container by explicitly defining the entrypoint -``` bash +```bash docker run -it --entrypoint bash freyr-dev # Alternatively, create a handy alias @@ -1082,7 +1092,7 @@ Optionally, you can use these interesting flags to customize the experience. The freyr source would be available in the `/freyr` directory within the container along with a globally registered command `freyr` for calling the script. -For more information and documentation about docker, please refer to its official website: +For more information and documentation about docker, please refer to its official site: - - diff --git a/package.json b/package.json index 724335c..bdbd57d 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,6 @@ }, "license": "Apache-2.0", "dependencies": { - "@babel/eslint-parser": "^7.17.0", "@miraclx/apple-music": "^0.4.0", "async": "^3.2.0", "axios": "^0.26.0", @@ -90,6 +89,7 @@ "yt-search": "^2.10.3" }, "devDependencies": { + "@babel/eslint-parser": "^7.17.0", "eslint": "8.9.0", "eslint-plugin-prettier": "4.0.0", "prettier": "2.5.1" diff --git a/src/cli_server.js b/src/cli_server.js index c5c3e17..3cfee52 100644 --- a/src/cli_server.js +++ b/src/cli_server.js @@ -19,7 +19,7 @@ function wrapHTML(opts) { border-radius: 14px; text-align: center; } - + .center-v { margin: 0; position: absolute; @@ -28,7 +28,7 @@ function wrapHTML(opts) { transform: translate(-50%, -50%); } - +

FreyrCLI


diff --git a/src/parse_range.js b/src/parse_range.js index 34a37e9..33c5b04 100644 --- a/src/parse_range.js +++ b/src/parse_range.js @@ -70,12 +70,14 @@ function initTest() { console.log(parseBlock.parsed); values.forEach(value => console.log(`[${value.toString().padStart(2)}] ${parseBlock.check(value)}`)); } + // jscpd:ignore-start function test_time(spec, values) { console.log('%j', spec); const parseBlock = parseRange.time(spec); console.log(parseBlock.parsed); values.forEach(value => console.log(`[${value.toString().padStart(2)}] ${parseBlock.check(value)}`)); } + // jscpd:ignore-end test_num(' ', [1, 2, 3]); test_num('7 ', [6, 7, 8]); diff --git a/src/services/apple_music.js b/src/services/apple_music.js index 291d91c..7a65c97 100644 --- a/src/services/apple_music.js +++ b/src/services/apple_music.js @@ -290,10 +290,10 @@ class AppleMusic { (await this.getArtist(uris)).albums.map(album => `apple_music:album:${album}`), 100, store, - async (items, storefront) => - Promise.mapSeries( - (await this.#store.core.albums.get(`?ids=${items.map(item => item.refID).join(',')}`, {storefront})).data, - album => this.wrapAlbumData(album), + (items, storefront) => + this.getAlbum( + items.map(item => item.uri), + storefront, ), ); } diff --git a/src/services/youtube.js b/src/services/youtube.js index df39012..ca8e4db 100644 --- a/src/services/youtube.js +++ b/src/services/youtube.js @@ -20,6 +20,18 @@ class YouTubeSearchError extends Error { } } +function _getSearchArgs(artists, track, duration) { + if (typeof track === 'number') [track, duration] = [, track]; + if (!Array.isArray(artists)) + if (track && artists) artists = [artists]; + else [artists, track] = [[], artists || track]; + if (typeof track !== 'string') throw new Error(' must be a valid string'); + if (artists.some(artist => typeof artist !== 'string')) + throw new Error(', if defined must be a valid array of strings'); + if (duration && typeof duration !== 'number') throw new Error(', if defined must be a valid number'); + return [artists, track, duration]; +} + /** * @typedef {( * { @@ -276,14 +288,7 @@ class YouTubeMusic { * @returns {YouTubeSearchResult} YouTubeMusicSearchResults */ async search(artists, track, duration) { - if (typeof track === 'number') [track, duration] = [, track]; - if (!Array.isArray(artists)) - if (track && artists) artists = [artists]; - else [artists, track] = [[], artists || track]; - if (typeof track !== 'string') throw new Error(' must be a valid string'); - if (artists.some(artist => typeof artist !== 'string')) - throw new Error(', if defined must be a valid array of strings'); - if (duration && typeof duration !== 'number') throw new Error(', if defined must be a valid number'); + [artists, track, duration] = _getSearchArgs(artists, track, duration); const results = await this.#search({query: [track, ...artists].join(' ')}); const strippedMeta = textUtils.stripText([...track.split(' '), ...artists]); @@ -384,14 +389,7 @@ class YouTube { * @returns {YouTubeSearchResult} YouTubeSearchResults */ async search(artists, track, duration) { - if (typeof track === 'number') [track, duration] = [, track]; - if (!Array.isArray(artists)) - if (track && artists) artists = [artists]; - else [artists, track] = [[], artists || track]; - if (typeof track !== 'string') throw new Error(' must be a valid string'); - if (artists.some(artist => typeof artist !== 'string')) - throw new Error(', if defined must be a valid array of strings'); - if (duration && typeof duration !== 'number') throw new Error(', if defined must be a valid number'); + [artists, track, duration] = _getSearchArgs(artists, track, duration); const strippedArtists = textUtils.stripText(artists); const strippedMeta = [...textUtils.stripText(track.split(' ')), ...strippedArtists]; diff --git a/src/stack_logger.js b/src/stack_logger.js index a5cd452..dd4a058 100644 --- a/src/stack_logger.js +++ b/src/stack_logger.js @@ -182,8 +182,7 @@ class StackLogger { * @param {...any} msgs Messages to write out */ error(...msgs) { - this._write(this.getText(this.#store.indent, msgs).concat('\n'), process.stderr, true); - return this.#store.autoTick ? this.tick(this.#store.indentSize) : this; + return this.warn(...msgs); } /**