[
  {
    "path": ".github/CODEOWNERS",
    "content": "* @port19x\nREADME.md @justchokingaround\nani-cli @Derisis13\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bug-report.md",
    "content": "---\nname: Bug report\nabout: Ran into some unexpected behaviour? NOT FOR FEATURE REQUESTS\ntitle: ''\nlabels: 'priority 2: medium, type: bug'\nassignees: ''\n\n---\n## **Make sure you are on the latest version by running `ani-cli -U`**\n\n**Metadata (please complete the following information)**\nVersion: [e.g. 4.7.6, run `ani-cli -V` to find out]\nOS: [e.g. Windows 10 / Linux Mint 20.3]\nShell: [e.g. zsh, run `readlink /bin/sh` to get your shell]\nAnime: [e.g. flcl] (if applicable)\n\n**Describe the bug**\nDownloading is broken.\nIt says something about an unsupported protocol, see screenshot.\n\n**Steps To Reproduce**\n\n1. Run `ani-cli -d flcl`\n2. Choose 2 (fooly-cooly)\n3. Choose episode 1\n\n**Expected behavior**\nDownloading should work\n\n**Screenshots (if applicable; you can just drag the image onto github. remove the following line if not needed)**\n![image](https://user-images.githubusercontent.com/82055622/151030428-2e78d15f-4ba9-4d86-b6f3-8307557b4b29.png)\n\n**Additional context**\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/feature_request.md",
    "content": "---\nname: Feature request\nabout: Are we missing your favorite feature?\ntitle: ''\nlabels: 'priority 4: wishlist, type: feature request'\nassignees: ''\n\n---\n\n**Is your feature request related to a problem? Please describe.**\nThere is a better player for mac users than mpv.\nIt's called iina and is a mpv frontend written in swift.\nIt bugs me that I can't use it yet.\n\n**Describe the solution you'd like**\nPlease add iina, maybe through a `-i` flag analogous to the vlc `-v` flag\n\n**Describe alternatives you've considered**\nMaybe support any player string by the user.\nBut I assume thats drastically more difficult.\n\n**Additional context**\niina is just an mpv frontend and accepts its flags.\nNeedless to say it can play urls.\n"
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "content": "# Pull Request Template\n\n## Type of change\n\n- [ ] Bug fix\n- [ ] Feature\n- [ ] Documentation update\n\n## Description\n\n*ramble here*\n\n## Checklist\n\n- [ ] any anime playing\n- [ ] bumped version\n---\n- [ ] next, prev and replay work\n- [ ] `-c` history and continue work\n- [ ] `-d` downloads work\n- [ ] `-s` syncplay works\n- [ ] `-q` quality works\n- [ ] `-v` vlc works\n- [ ] `-e` (select episode) aka `-r` (range selection) works\n- [ ] `-S` select index works\n- [ ] `--skip` ani-skip works\n- [ ] `--skip-title` ani-skip title argument works\n- [ ] `--no-detach` no detach works\n- [ ] `--exit-after-play` auto exit after playing works\n- [ ] `--nextep-countdown` countdown to next ep works\n- [ ] `--dub` and regular (sub) mode both work\n- [ ] all providers return links (not necessarily on a single anime, use debug mode to confirm)\n---\n- [ ] `-h` help info is up to date\n- [ ] Readme is up to date\n- [ ] Man page is up to date\n\n## Additional Testcases\n\n- The safe bet: One Piece\n- Episode 0: Saenai Heroine no Sodatekata ♭\n- Unicode: Saenai Heroine no Sodatekata ♭\n- Non-whole episodes: Tensei shitara slime datta ken (ep. 24.5, ep. 24.9)\n- All Providers: Youkoso Jitsuryoku Shijou Shugi no Kyoushitsu e (TV) (3 m3u8, 3 mp4, 1 fast4speed, 1 sharepoint)\n- The examples of the help text\n"
  },
  {
    "path": ".github/workflows/ani-cli.yml",
    "content": "name: 'ani-cli checks'\non:\n  push:\n    branches:\n      - master\n  pull_request:\n    paths:\n      - \"**ani-cli\"\n\njobs:\n  sh-checker:\n    name: Shellcheck + Shfmt\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@v4\n    - name: Run the sh-checker\n      uses: luizm/action-sh-checker@master\n      env:\n        SHELLCHECK_OPTS: -s sh -o all -e 2250\n        SHFMT_OPTS: -i 4 -ci -d\n      with:\n        sh_checker_exclude: \"_ani-cli-bash _ani-cli-zsh\"\n      \n  check-exec:\n    name: Executable Bit\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@v4\n    - name: test exec bit\n      run: test -x \"./ani-cli\"\n\n  check-no-awk:\n    name: No Awk Allowed\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@v4\n    - name: verify that noone added awk\n      run: '! grep awk \"./ani-cli\"'\n"
  },
  {
    "path": ".github/workflows/inverse-ani.yml",
    "content": "# Added due to required but conditional checks\n# Read more: https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/troubleshooting-required-status-checks#handling-skipped-but-required-checks\n\nname: 'ani-cli checks'\non:\n  pull_request:\n    paths-ignore:\n      - \"/ani-cli\"\njobs:\n  sh-checker:\n    name: Shellcheck + Shfmt\n    runs-on: ubuntu-latest\n    steps:\n      - run: 'echo \"Not required: did not modify ani-cli\"'\n  check-exec:\n    name: Executable Bit\n    runs-on: ubuntu-latest\n    steps:\n      - run: 'echo \"Not required: did not modify ani-cli\"'\n  version-bump:\n    name: Version Bump\n    runs-on: ubuntu-latest\n    steps:\n      - run: 'echo \"Not required: did not modify ani-cli\"'\n"
  },
  {
    "path": ".github/workflows/inverse-md.yml",
    "content": "# Added due to required but conditional checks\n# Read more: https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/troubleshooting-required-status-checks#handling-skipped-but-required-checks\nname: 'markdown checks'\non:\n  pull_request:\n    paths-ignore:\n      - \"**.md\"\njobs:\n  dead-links:\n    name: Dead Link Checker\n    runs-on: ubuntu-latest\n    steps:\n      - run: 'echo \"Not required: did not modify documentation\"'\n  trailing-ws:\n    name: Find Trailing Whitespace\n    runs-on: ubuntu-latest\n    steps:\n      - run: 'echo \"Not required: did not modify documentation\"'\n"
  },
  {
    "path": ".github/workflows/markdown.yml",
    "content": "name: 'markdown checks'\non:\n  push:\n    branches:\n      - master\n  pull_request:\n    paths: \n      - \"**.md\"\n\njobs:\n  dead-links:\n    name: Dead Link Checker\n    runs-on: ubuntu-latest\n    steps:\n    - name: Run DeadFinder\n      uses: hahwul/deadfinder@1.2.4\n      id: broken-link\n      with:\n        command: file\n        target: \"**.md\"\n  trailing-ws:\n    name: Find Trailing Whitespace\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      - uses: ocular-d/trailing-spaces@0.0.2\n"
  },
  {
    "path": ".github/workflows/title.yml",
    "content": "name: \"semantic pr title\"\non: \n  pull_request:\n    types: [opened, edited, ready_for_review, synchronize]\npermissions:\n  pull-requests: read\n\njobs:\n  main:\n    name: Validate PR Title\n    runs-on: ubuntu-latest\n    steps:\n      - uses: amannn/action-semantic-pull-request@v5\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n"
  },
  {
    "path": ".github/workflows/version.yml",
    "content": "name: 'ani-cli checks'\non:\n  pull_request:\n    paths: \n      - \"/ani-cli\"\n      \njobs:\n  version-bump:\n    name: Version Bump\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@v4\n      with:\n        fetch-depth: 0\n    - name: check version bump\n      run: git diff origin/master | grep version_number\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# Contribution Guidelines\n\n## Pull Requests\n\n- Appease the linter\n- Bump the version\n- Adjust the Readme according to your changes (if applicable)\n- No extra dependencies unless absolutely necessary\n- If you're fixing an issue, open an issue as well or link existing one\n\n## Issues\n\n- Use the issue templates\n- When requesting a feature, check it hasn't been [rejected](https://github.com/pystardust/ani-cli/issues/523) previously\n- Provide screenshot if applicable\n\n## How else can I help?\n\n- Join the [discord](https://discord.gg/aqu7GpqVmR)\n- Take part in troubleshooting and testing\n- Star the repo\n- Follow the maintainers\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<https://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<https://www.gnu.org/licenses/why-not-lgpl.html>.\n"
  },
  {
    "path": "README.md",
    "content": "<p align=center>\n<br>\n<a href=\"http://makeapullrequest.com\"><img src=\"https://img.shields.io/badge/PRs-welcome-brightgreen.svg\"></a>\n<a href=\"#Linux\"><img src=\"https://img.shields.io/badge/os-linux-brightgreen\">\n<a href=\"#MacOS\"><img src=\"https://img.shields.io/badge/os-mac-brightgreen\">\n<a href=\"#Android\"><img src=\"https://img.shields.io/badge/os-android-brightgreen\">\n<a href=\"#Windows\"><img src=\"https://img.shields.io/badge/os-windows-yellowgreen\">\n<a href=\"#iOS\"><img src=\"https://img.shields.io/badge/os-ios-yellow\">\n<a href=\"#Steam-deck\"><img src=\"https://img.shields.io/badge/os-steamdeck-yellow\">\n<br>\n<h1 align=\"center\">\n<a href=\"https://discord.gg/aqu7GpqVmR\"><img src=\"https://invidget.switchblade.xyz/aqu7GpqVmR\"></a>\n<a href=\"matrix.md\"><img src=\"/.assets/matrix-logo.svg\" height=110></a>\n<br>\n<a href=\"https://github.com/port19x\"><img src=\"https://img.shields.io/badge/lead-port19x-lightblue\"></a>\n<a href=\"https://github.com/CoolnsX\"><img src=\"https://img.shields.io/badge/maintainer-CoolnsX-blue\"></a>\n<a href=\"https://github.com/justchokingaround\"><img src=\"https://img.shields.io/badge/maintainer-justchokingaround-blue\"></a>\n<a href=\"https://github.com/Derisis13\"><img src=\"https://img.shields.io/badge/maintainer-Derisis13-blue\"></a>\n<a href=\"https://github.com/71zenith\"><img src=\"https://img.shields.io/badge/maintainer-71zenith-blue\"></a>\n<a href=\"https://github.com/ykhan21\"><img src=\"https://img.shields.io/badge/maintainer-ykhan21-blue\"></a>\n\n</p>\n\n<h3 align=\"center\">\nA cli to browse and watch anime (alone AND with friends). This tool scrapes the site <a href=\"https://allmanga.to/\">allmanga.</a>\n</h3>\n\n<h1 align=\"center\">\n\tShowcase\n</h1>\n\n[ani-cli-demo.webm](https://user-images.githubusercontent.com/44473782/224679247-0856e652-f187-4865-bbcf-5a8e5cf830da.webm)\n\n## Table of Contents\n\n- [Fixing errors](#fixing-errors)\n- [Install](#install)\n  - [Tier 1: Linux, Mac, Android](#tier-1-support-linux-mac-android)\n  - [Tier 2: Windows, WSL, iOS, Steam Deck, FreeBSD](#tier-2-support-windows-wsl-ios-steam-deck-freebsd)\n  - [From Source](#installing-from-source)\n- [Uninstall](#uninstall)\n- [Dependencies](#dependencies)\n  - [Ani-Skip](#ani-skip)\n- [FAQ](#faq)\n- [Homies](#homies)\n- [Contribution Guidelines](./CONTRIBUTING.md)\n- [Disclaimer](./disclaimer.md)\n\n## Fixing errors\n\nIf you encounter `No results found` (and are sure the prompt was correct) or any breaking issue, then make sure you are on **latest version** by typing\n`sudo ani-cli -U` to update on Linux, Mac and Android. On Windows, run `ani-cli -U`.\nIf after this the issue persists then open an issue.\n\n## Install\n\n[![Packaging status](https://repology.org/badge/vertical-allrepos/ani-cli.svg?minversion=4.0)](https://repology.org/project/ani-cli/versions)\n\n### Tier 1 Support: Linux, Mac, Android\n\n*These Platforms have rock solid support and are used by maintainers and large parts of the userbase.*\n\n<details><summary><b>Linux</b></summary>\n\n#### Native Packages\n\n*Native packages have a more robust update cycle, but sometimes they are slow to upgrade. \\\nIf the one for your platform is up-to-date we suggest going with it.*\n\n<details><summary>Debian 13/unstable</summary>\n\n```sh\nsudo apt install ani-cli\n```\n</details>\n\n<details><summary>Fedora</summary>\n\nTo install mpv (and vlc) you need _RPM Fusion free_ enabled. Simply follow the instructions here: https://rpmfusion.org/Configuration\nTo be able to install syncplay, you'll need to enable this copr repo (instructions included): https://copr.fedorainfracloud.org/coprs/batmanfeynman/syncplay/.\n\nTo install ani-cli:\n```sh\nsudo dnf copr enable derisis13/ani-cli\nsudo dnf install ani-cli\n```\n*If for your distro uses rpm and you would like to see a native package, open an issue.*\n\n</details><details><summary>Arch</summary>\n\nBuild and install from the AUR:\n```sh\nyay -S ani-cli\n```\nAlso consider `ani-cli-git`\n\n</details><details><summary>Gentoo</summary>\n\nBuild and install from the GURU:\n```sh\nsudo eselect repository enable guru\nsudo emaint sync -r guru\nsudo emerge -a ani-cli\n```\nConsider using the 9999 ebuild.\n```sh\nsudo emerge -a =app-misc/ani-cli-9999\n```\n\n</details><details><summary>OpenSuse</summary>\n\nOn Suse the provided MPV and VLC packages are missing features that are used by ani-cli. The only required is the \"Only Essentials\" repository which has versions for each Suse release.\nYou can find instructions on this [here](https://en.opensuse.org/Additional_package_repositories#Packman).\n\nTo add the ani-cli copr repo, update then install ani-cli run (on both versions):\n```sh\nzypper addrepo https://download.copr.fedorainfracloud.org/results/derisis13/ani-cli/opensuse-tumbleweed-x86_64/ ani-cli\nzypper dup\nzypper install ani-cli\n```\nYou'll get a warning about `Signature verification failed [4-Signatures public key is not available]` but this can be ignored from the prompt.\n\n*Note: package is noarch, so any architecture should work, even though the repo is labelled x86-64*\n\n</details></details><details><summary><b>MacOS</b></summary>\n\nInstall dependencies [(See below)](#dependencies)\n\nInstall [HomeBrew](https://docs.brew.sh/Installation) if not installed.\n\n```sh\ngit clone \"https://github.com/pystardust/ani-cli.git\" && cd ./ani-cli\ncp ./ani-cli \"$(brew --prefix)\"/bin\ncd .. && rm -rf ./ani-cli\n```\n\n*To install (with Homebrew) the dependencies required on Mac OS, you can run:*\n\n```sh\nbrew install curl grep aria2 ffmpeg git fzf yt-dlp && \\\nbrew install --cask iina\n```\n*Why iina and not mpv? Drop-in replacement for mpv for MacOS. Integrates well with OSX UI. Excellent support for M1. Open Source.*\n\n</details><details><summary><b>Android</b></summary>\n\nInstall termux [(Guide)](https://termux.com/)\n\n#### Termux package\n\n```sh\npkg up -y\npkg install ani-cli\n```\nIf you're using Android 14 make sure to run this due to [#1206](https://github.com/pystardust/ani-cli/issues/1206):\n```sh\npkg install termux-am\n```\n\nFor players you can use the apk (playstore/fdroid) versions of mpv and vlc. Note that these cannot be checked from termux so a warning is generated when checking dependencies.\n\n</details>\n\n### Tier 2 Support: Windows, WSL, iOS, Steam Deck, FreeBSD\n\n*While officially supported (except FreeBSD), installation is more involved on these platforms and sometimes issues arise. \\\nReach out if you need help.*\n\n<details><summary><b>Windows</b></summary>\n\n`ani-cli` is on scoop. Please read further for setup instructions.\n\nWe will set up the bash.exe that comes with Git for Windows to be used with Windows Terminal. You may use terminals such as Wezterm or Alacritty, but this guide only covers Windows Terminal. The Git Bash terminal (i.e., mintty) [has problems with fzf](#windows-known-problems-and-solutions).\n\nFirst, you'll need to install the scoop package manager. [(Install)](https://scoop.sh/) Follow **quickstart**.\n\nNext, get Windows Terminal. It comes preinstalled on Windows 11. If you do not have it, install it by running the following commands in powershell.\n\n```sh\nscoop bucket add extras\nscoop install extras/windows-terminal\n```\n\nNext, get git. If you have it, please update it. If you do not already have it, install it by running `scoop install git` in powershell.\n\nEnsure that Git Bash is present in the Windows Terminal tab drop down, as shown below.\n\n![windows-terminal-git-bash-1.png](.assets/windows-terminal-git-bash-1.png)\n\nIf it is not there, please add it. To add it, first click the drop-down button beside the new tab button (shown above).\n\nThen, navigate to `Settings > Profiles > Add a new profile`. Click `+ New empty profile`.\n\n![windows-terminal-git-bash-2.png](.assets/windows-terminal-git-bash-2.png)\n\nNext:\n- If you installed git with scoop: Set *Name* as \"Git Bash\", set *Command line* as `%GIT_INSTALL_ROOT%\\bin\\bash.exe -i -l`, and set *Icon* as `%GIT_INSTALL_ROOT%\\mingw64\\share\\git\\git-for-windows.ico`.\n- If you installed git by other means: Set *Name* as \"Git Bash\", set *Command line* as `C:\\Program Files\\Git\\bin\\bash.exe -i -l`, and set *Icon* as `C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico`.\n\nNext, set *Starting Directory* to `%USERPROFILE%`, and ensure that *Hide profile from dropdown* is set to \"Off\" (otherwise you won't be able to see this profile in the drop down).\n\n![windows-terminal-git-bash-3.png](.assets/windows-terminal-git-bash-3.png)\n\nNow save your changes.\n\nYou will use this profile to run `ani-cli` in this bash shell.\nUnder Startup in Windows Terminal Settings, you may set this profile as the default so that you do not have to switch to it every time you want to run `ani-cli`.\n\n![windows-terminal-git-bash-4.png](.assets/windows-terminal-git-bash-4.png)\n\nNow restart Windows Terminal. In the Git Bash profile, install `ani-cli` by running the following commands.\n\n```sh\nscoop bucket add extras\nscoop install ani-cli\n```\n\nNext, install its dependencies.\n\n```sh\nscoop bucket add extras\nscoop install fzf ffmpeg mpv\n```\n\nConsider also installing `yt-dlp` and `aria2` for downloading to work.\n\nRestart Windows Terminal. Go to the Git Bash profile and update `ani-cli` with `ani-cli -U`. You will use this keep ani-cli up-to-date.\n\nNow you can use ani-cli. Read the output of `ani-cli -h` for more help.\n\n#### Windows: Known Problems and Solutions\n\nIf you have a problem, please update ani-cli to the latest version with `ani-cli -U`. If you still have a problem, please read further.\n\n- Stuck in \"Search anime:\". This shouldn't happen if you are using the Windows Terminal + Bash setup described above. It happens if you are using the Git Bash terminal (i.e., the mintty terminal). This is a problem between fzf and mintty, which should be resolved in future versions of fzf. For the time being, either use the Windows Terminal setup described above or, if you are dead-set on using the mintty terminal, run `export MSYS=enable_pcon` before running ani-cli.\n- \"No such file or directory\" or WSL-related errors: This shouldn't happen if you are using the Window Terminal + Bash setup described above. This happens if you run ani-cli in powershell or cmd. This is due WSL's bash.exe being called instead of Git for Windows' bash.exe in `%USERPROFILE%\\scoop\\shims\\ani-cli.cmd`. If you must use powershell or cmd, edit the `%USERPROFILE%\\scoop\\shims\\ani-cli.cmd` file. In File Explorer, go to the `C:\\Users\\USERNAME\\scoop\\shims` directory and open the `ani-cli.cmd` file with notepad. Next:\n    - If you installed git with scoop, replace `@bash` with `@\"%GIT_INSTALL_ROOT%\\bin\\bash.exe\"`, or\n    - If you installed git by other means, replace `@bash` with `@\"C:\\Program Files\\Git\\bin\\bash.exe\"`.\nThis should be fixed if the ani-cli scoop manifest gets updated in [this PR](https://github.com/ScoopInstaller/Extras/pull/13342).\n- curl can cause issues. ani-cli has been tested unsuccessfully with curl `7.83.1` and successfully with `7.86.0`. If you run into issues, try installing a newer one with scoop.\n- If you installed mpv with scoop, your mpv configuration will get read from `C:\\Users\\USERNAME\\scoop\\apps\\mpv\\current\\portable_config`. See [the mpv documentation](https://mpv.io/manual/stable/) regarding `portable_config` for more details.\n\n</details><details><summary><b>WSL</b></summary>\n\nFollow the installation instructions of your Linux distribution.\n\nNote that the media player (mpv or vlc) will need to be installed on Windows, not WSL. See the justification for this in the comment [(here)](https://github.com/pystardust/ani-cli/issues/1266#issuecomment-1926945757). Instructions on how to use the media player from WSL instead are also included in the linked comment.\n\nWhen installing the media player on Windows, make sure that it is on the Windows Path. An easy way to ensure this is to download the media player with a package manager (on Windows, not WSL) such as scoop.\n\n</details><details><summary><b>iOS</b></summary>\n\nInstall iSH and VLC from the app store.\n\nMake sure apk is updated using\n```apk update; apk upgrade```\nthen run this:\n```sh\napk add grep sed curl fzf git aria2 ncurses patch\napk add ffmpeg\ngit clone --depth 1 https://github.com/pystardust/ani-cli ~/.ani-cli\ncp ~/.ani-cli/ani-cli /usr/local/bin/ani-cli\nchmod +x /usr/local/bin/ani-cli\nrm -rf ~/.ani-cli\n```\nnote that downloading is going to be very slow. This is an iSH issue, not an ani-cli issue.\n</details>\n\n<details><summary><b>Steam Deck</b></summary>\n\n#### Copypaste script:\n\n* Switch to Desktop mode (`STEAM` Button > Power > Switch to Desktop)\n* Open `Konsole` (Steam Deck Icon in bottom left corner > System > Konsole)\n* Copy the script, paste it in the CLI and press Enter(\"A\" button on Steam Deck)\n\n```sh\n[ ! -d ~/.local/bin ] && mkdir ~/.local/bin && echo \"export PATH=$HOME/.local/bin:\\$PATH\" >> \".$(echo $SHELL | sed -nE \"s|.*/(.*)\\$|\\1|p\")rc\"\n\ngit clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf\n~/.fzf/install\n\nmkdir ~/.aria2c\ncurl -o ~/.aria2c/aria2-1.36.0.tar.bz2 https://github.com/q3aql/aria2-static-builds/releases/download/v1.36.0/aria2-1.36.0-linux-gnu-64bit-build1.tar.bz2\ntar xvf ~/.aria2c/aria2-1.36.0.tar.bz2 -C ~/.aria2c/\ncp ~/.aria2c/aria2-1.36.0-linux-gnu-64bit-build1/aria2c ~/.local/bin/\nchmod +x ~/.local/bin/aria2c\n\ncurl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o ~/.local/bin/yt-dlp\nchmod +x ~/.local/bin/yt-dlp\n\nmkdir ~/.patch\ncurl -o ~/.patch/patch.tar.zst https://mirror.sunred.org/archlinux/core/os/x86_64/patch-2.8-1-x86_64.pkg.tar.zst\ntar xvf ~/.patch/patch.tar.zst -C ~/.patch/\ncp ~/.patch/usr/bin/patch ~/.local/bin/\n\ngit clone https://github.com/pystardust/ani-cli.git ~/.ani-cli\ncp ~/.ani-cli/ani-cli ~/.local/bin/\n\nflatpak install io.mpv.Mpv\n```\npress enter(\"A\" button on Steam Deck) on questions\n\n#### Installation in steps:\n\n##### Install mpv (Flatpak version):\n\n```sh\nflatpak install io.mpv.Mpv\n```\npress enter(\"A\" button on Steam Deck) on questions\n\n##### Install [fzf](https://github.com/junegunn/fzf):\n\n```sh\ngit clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf\n~/.fzf/install\n```\npress enter(\"A\" button on Steam Deck) on questions\n\n##### Make a ~/.local/bin folder if doesn't exist and add it to $PATH\n\n```sh\n[ ! -d ~/.local/bin ] && mkdir ~/.local/bin && echo \"export PATH=$HOME/.local/bin:\\$PATH\" >> \".$(echo $SHELL | sed -nE \"s|.*/(.*)\\$|\\1|p\")rc\"\n```\n\n##### Install [aria2](https://github.com/aria2/aria2) (needed for download feature only):\n\n```sh\nmkdir ~/.aria2c\ncurl -o ~/.aria2c/aria2-1.36.0.tar.bz2 https://github.com/q3aql/aria2-static-builds/releases/download/v1.36.0/aria2-1.36.0-linux-gnu-64bit-build1.tar.bz2\ntar xvf ~/.aria2c/aria2-1.36.0.tar.bz2 -C ~/.aria2c/\ncp ~/.aria2c/aria2-1.36.0-linux-gnu-64bit-build1/aria2c ~/.local/bin/\nchmod +x ~/.local/bin/aria2c\n```\n\n##### Install [yt-dlp](https://github.com/yt-dlp/yt-dlp) (needed for download feature only):\n\n```sh\ncurl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o ~/.local/bin/yt-dlp\nchmod +x ~/.local/bin/yt-dlp\n```\n\n##### Install [patch](https://savannah.gnu.org/projects/patch/) (needed for self-update feature [ -U ] ):\n\n```sh\nmkdir ~/.patch\ncurl -o ~/.patch/patch.tar.zst https://mirror.sunred.org/archlinux/core/os/x86_64/patch-2.8-1-x86_64.pkg.tar.zst\ntar xvf ~/.patch/patch.tar.zst -C ~/.patch/\ncp ~/.patch/usr/bin/patch ~/.local/bin/\n```\n\n##### Install ani-cli:\n\n```sh\ngit clone https://github.com/pystardust/ani-cli.git ~/.ani-cli\ncp ~/.ani-cli/ani-cli ~/.local/bin/\n```\n\n##### Optional: add desktop entry:\n\n```\necho '[Desktop Entry]\nEncoding=UTF-8\nType=Application\nExec=bash -c \"source $HOME/.'$(echo $SHELL | sed -nE \"s|.*/(.*)\\$|\\1|p\")'rc && konsole --fullscreen -e ani-cli\"\nName=ani-cli' > $HOME/.local/share/applications/ani-cli.desktop\n```\nThe .desktop entry will allow to start ani-cli in Konsole directly from \"Gaming Mode\"\nIn Steam Desktop app:\n`Add game` > `Add a non-steam game` > tick a box for `ani-cli` > `Add selected programs`\n</details>\n\n<details><summary><b>FreeBSD</b></summary>\n\n#### Copypaste script:\n\n```sh\nsudo pkg install mpv fzf aria2 yt-dlp patch git\ngit clone \"https://github.com/pystardust/ani-cli.git\"\nsudo cp ani-cli/ani-cli /usr/local/bin\nrm -rf ani-cli\n```\n\n#### Installation in steps:\n\n##### Install dependencies:\n\n```sh\nsudo pkg install mpv fzf aria2 yt-dlp patch\n```\n\n##### Install ani-cli:\n\ninstall git if you haven't already\n\n```sh\nsudo pkg install git\n```\n\ninstall from source:\n\n```sh\ngit clone \"https://github.com/pystardust/ani-cli.git\"\nsudo cp ani-cli/ani-cli /usr/local/bin\nrm -rf ani-cli\n```\n\n</details>\n\n### Installing from source\n\n*This method works for any unix-like operating system and is a baseline for porting efforts.*\n\nInstall dependencies [(See below)](#dependencies)\n\n```sh\ngit clone \"https://github.com/pystardust/ani-cli.git\"\nsudo cp ani-cli/ani-cli /usr/local/bin\nrm -rf ani-cli\n```\n\n## Uninstall\n\n<details>\n\n* apt:\n```sh\nsudo apt remove ani-cli\n# to remove the repository from apt\nsudo rm -f /etc/apt/trusted.gpg.d/ani-cli.asc /etc/apt/sources.list.d/ani-cli-debian.list\n```\n* dnf:\n```sh\nsudo dnf remove ani-cli      # for ani-cli\n# disable the repo in dnf\ndnf copr disable derisis13/ani-cli\n```\nYou might want to uninstall RPM fusion if you don't use it otherwise\n* zypper:\n```sh\nzypper remove ani-cli\nzypper removerepo ani-cli\n```\nYou might want to remove `packman-essentials` if you don't need it otherwise\n* AUR:\n```sh\nyay -R ani-cli\n```\n* Scoop:\n```sh\nscoop uninstall ani-cli\n```\n* Linux:\n```sh\nsudo rm \"/usr/local/bin/ani-cli\"\n```\n* Mac:\n```sh\nrm \"$(brew --prefix)/bin/ani-cli\"\n```\n* Windows:\nIn **Git Bash** run (as administrator):\n```sh\nrm \"/usr/bin/ani-cli\"\n```\n* Termux package\n```sh\npkg remove ani-cli\n```\n* Android:\n```sh\nrm \"$PREFIX/bin/ani-cli\"\n```\n* Steam Deck\n```sh\nrm \"~/.local/bin/ani-cli\"\nrm -rf ~/.ani-cli\n```\noptionally: remove dependencies:\n```sh\nrm ~/.local/bin/aria2c\nrm ~/.local/bin/yt-dlp\nrm -rf \"~/.aria2\"\nrm -rf \"~/.fzf\"\nflatpak uninstall io.mpv.Mpv\n```\n* iOS\n```\nrm -rf /usr/local/bin/ani-cli\n```\nTo uninstall other dependencies:\n```\napk del grep sed curl fzf git aria2 ffmpeg ncurses\n```\n\n</details>\n\n## Dependencies\n\n- grep\n- sed\n- curl\n- mpv - Video Player\n- iina - mpv replacement for MacOS\n- aria2c - Download manager\n- yt-dlp - m3u8 Downloader\n- ffmpeg - m3u8 Downloader (fallback)\n- fzf - User interface\n- ani-skip (optional)\n- patch - Self updating\n\n### Ani-Skip\n\nAni-skip is a script to automatically skip anime opening sequences, making it easier to watch your favorite shows without having to manually skip the intros each time (from the original [README](https://github.com/synacktraa/ani-skip/tree/master#a-script-to-automatically-skip-anime-opening-sequences-making-it-easier-to-watch-your-favorite-shows-without-having-to-manually-skip-the-intros-each-time)).\n\nFor install instructions visit [ani-skip](https://github.com/synacktraa/ani-skip).\n\nAni-skip uses the external lua script function of mpv and as such – for now – only works with mpv.\n\n**Warning:** For now, ani-skip does **not** seem to work under Windows.\n\n**Note:** It may be, that ani-skip won't know the anime you're trying to watch. Try using the `--skip-title <title>` command line argument. (It uses the [aniskip API](https://github.com/lexesjan/typescript-aniskip-extension/tree/main/src/api/aniskip-http-client) and you can contribute missing anime or ask for including it in the database on their [discord server](https://discord.com/invite/UqT55CbrbE)).\n\n## FAQ\n<details>\n\t\n* Can I change subtitle language or turn them off? - No, the subtitles are baked into the video.\n* Can I watch dub? - Yes, use `--dub`.\n* Can I change dub language? - No.\n* Can I change media source? - No (unless you can scrape that source yourself).\n* Can I use vlc? - Yes, use `--vlc` or `export ANI_CLI_PLAYER=vlc`.\n* Can I adjust resolution? - Yes, use `-q resolution`, for example `ani-cli -q 1080`.\n* How can I download? - Use `-d`, it will download into your working directory.\n* Can i change download folder? - Yes, set the `ANI_CLI_DOWNLOAD_DIR` to your desired location.\n* How can I bulk download? - `Use -d -e firstepisode-lastepisode`, for example `ani-cli onepiece -d -e 1-1000`.\n\n**Note:** All features are documented in `ani-cli --help`.\n\n</details>\n\n## Homies\n\n* [animdl](https://github.com/justfoolingaround/animdl): Ridiculously efficient, fast and light-weight (supports most sources: allmanga, zoro ... (Python)\n* [jerry](https://github.com/justchokingaround/jerry): stream anime with anilist tracking and syncing, with discord presence (Shell)\n* [anipy-cli](https://github.com/sdaqo/anipy-cli): ani-cli rewritten in python (Python)\n* [mangal](https://github.com/metafates/mangal): Download & read manga from any source with anilist sync (Go)\n* [lobster](https://github.com/justchokingaround/lobster): Watch movies and series from the terminal (Shell)\n* [mov-cli](https://github.com/mov-cli/mov-cli): Watch everything from your terminal. (Python)\n* [dra-cla](https://github.com/CoolnsX/dra-cla): ani-cli equivalent for korean dramas (Shell)\n* [redqu](https://github.com/port19x/redqu):  A media centric reddit client (Clojure)\n* [doccli](https://github.com/TowarzyszFatCat/doccli):  A cli to watch anime with POLISH subtitles (Python)\n* [GoAnime](https://github.com/alvarorichard/GoAnime): A TUI tool to browse, play, and download anime in Portuguese and English, with Discord RPC, AniList integration, and intro skipping. (Go)\n* [Curd](https://github.com/Wraient/curd): A CLI tool to watch anime with Anilist, Discord RPC, Skip Intro/Outro/Filler/Recap (Go)\n* [FastAnime](https://github.com/Benex254/FastAnime): browser anime experience from the terminal (Python)\n* [ani-skip](https://github.com/KilDesu/ani-skip): Automatically skip opening and ending sequences for IINA on MacOS (Typescript, official IINA plugin API)\n"
  },
  {
    "path": "ani-cli",
    "content": "#!/bin/sh\n\nversion_number=\"4.10.6\"\n\n# UI\n\nexternal_menu() {\n    [ \"$use_external_menu\" = \"1\" ] && rofi \"$1\" -sort -dmenu -i -width 1500 -p \"$2\" \"$3\"\n    [ \"$use_external_menu\" = \"2\" ] && dmenu -l 20 -p \"$2\"\n}\n\nlauncher() {\n    [ \"$use_external_menu\" = \"0\" ] && [ -z \"$1\" ] && set -- \"+m\" \"$2\"\n    [ \"$use_external_menu\" = \"0\" ] && fzf \"$1\" --reverse --cycle --prompt \"$2\"\n    [ \"$use_external_menu\" = \"1\" ] && external_menu \"$1\" \"$2\" \"$external_menu_args\"\n    [ \"$use_external_menu\" = \"2\" ] && external_menu \"$1\" \"$2\"\n}\n\nnth() {\n    stdin=$(cat -)\n    [ -z \"$stdin\" ] && return 1\n    line_count=\"$(printf \"%s\\n\" \"$stdin\" | wc -l | tr -d \"[:space:]\")\"\n    [ \"$line_count\" -eq 1 ] && printf \"%s\" \"$stdin\" | cut -f2,3 && return 0\n    prompt=\"$1\"\n    multi_flag=\"\"\n    [ $# -ne 1 ] && shift && multi_flag=\"$1\"\n    line=$(printf \"%s\" \"$stdin\" | cut -f1,3 | tr '\\t' ' ' | launcher \"$multi_flag\" \"$prompt\" | cut -d \" \" -f 1)\n    line_start=$(printf \"%s\" \"$line\" | head -n1)\n    line_end=$(printf \"%s\" \"$line\" | tail -n1)\n    [ -n \"$line\" ] || exit 1\n    if [ \"$line_start\" = \"$line_end\" ]; then\n        printf \"%s\" \"$stdin\" | grep -E '^'\"${line}\"'($|[[:space:]])' | cut -f2,3 || exit 1\n    else\n        printf \"%s\" \"$stdin\" | sed -n '/^'\"${line_start}\"'$/,/^'\"${line_end}$\"'/p' || exit 1\n    fi\n}\n\ndie() {\n    printf \"\\33[2K\\r\\033[1;31m%s\\033[0m\\n\" \"$*\" >&2\n    exit 1\n}\n\nhelp_info() {\n    printf \"\n    Usage:\n    %s [options] [query]\n    %s [query] [options]\n    %s [options] [query] [options]\n\n    Options:\n      -c, --continue\n        Continue watching from history\n      -d, --download\n        Download the video instead of playing it\n      -D, --delete\n        Delete history\n      -l, --logview\n        Show logs\n      -s, --syncplay\n        Use Syncplay to watch with friends\n      -S, --select-nth\n        Select nth entry\n      -q, --quality\n        Specify the video quality\n      -v, --vlc\n        Use VLC to play the video\n      -V, --version\n        Show the version of the script\n      -h, --help\n        Show this help message and exit\n      -e, --episode, -r, --range\n        Specify the number of episodes to watch\n      --dub\n        Play dubbed version\n      --rofi\n        Use rofi instead of fzf for the interactive menu\n      --dmenu\n        Use dmenu instead of fzf for the interactive menu\n      --skip\n        Use ani-skip to skip the intro of the episode (mpv only)\n      --no-detach\n        Don't detach the player (useful for in-terminal playback, mpv only)\n      --exit-after-play\n        Exit the player, and return the player exit code (useful for non interactive scenarios, mpv only)\n      --skip-title <title>\n        Use given title as ani-skip query\n      -N, --nextep-countdown\n        Display a countdown to the next episode\n      -U, --update\n        Update the script\n    Some example usages:\n      %s -q 720p banana fish\n      %s --skip --skip-title \\\"one piece\\\" -S 2 one piece\n      %s -d -e 2 cyberpunk edgerunners\n      %s --vlc cyberpunk edgerunners -q 1080p -e 4\n      %s blue lock -e 5-6\n      %s -e \\\"5 6\\\" blue lock\n    \\n\" \"${0##*/}\" \"${0##*/}\" \"${0##*/}\" \"${0##*/}\" \"${0##*/}\" \"${0##*/}\" \"${0##*/}\" \"${0##*/}\" \"${0##*/}\"\n    exit 0\n}\n\nversion_info() {\n    printf \"%s\\n\" \"$version_number\"\n    exit 0\n}\n\nupdate_script() {\n    update=\"$(curl -s -A \"$agent\" \"https://raw.githubusercontent.com/pystardust/ani-cli/master/ani-cli\")\" || die \"Connection error\"\n    update=\"$(printf '%s\\n' \"$update\" | diff -u \"$0\" -)\"\n    if [ -z \"$update\" ]; then\n        printf \"Script is up to date :)\\n\"\n    else\n        if printf '%s\\n' \"$update\" | patch \"$0\" -; then\n            printf \"Script has been updated\\n\"\n        else\n            die \"Can't update for some reason!\"\n        fi\n    fi\n    exit 0\n}\n\n# checks if dependencies are present\ndep_ch() {\n    for dep; do\n        command -v \"${dep%% *}\" >/dev/null || die \"Program \\\"${dep%% *}\\\" not found. Please install it.\"\n    done\n}\n\nwhere_iina() {\n    [ -e \"/Applications/IINA.app/Contents/MacOS/iina-cli\" ] && echo \"/Applications/IINA.app/Contents/MacOS/iina-cli\" && return 0\n    printf \"%s\" \"iina\" && return 0\n}\n\nwhere_mpv() {\n    command -v \"flatpak\" >/dev/null && flatpak info io.mpv.Mpv >/dev/null 2>&1 && printf \"%s\" \"flatpak_mpv\" && return 0\n    printf \"%s\" \"mpv\" && return 0\n}\n\n# SCRAPING\n\n# extract the video links from response of embed urls, extract mp4 links form m3u8 lists\nget_links() {\n    response=\"$(curl -e \"$allanime_refr\" -s \"https://${allanime_base}$*\" -A \"$agent\")\"\n    episode_link=\"$(printf '%s' \"$response\" | sed 's|},{|\\\n|g' | sed -nE 's|.*link\":\"([^\"]*)\".*\"resolutionStr\":\"([^\"]*)\".*|\\2 >\\1|p;s|.*hls\",\"url\":\"([^\"]*)\".*\"hardsub_lang\":\"en-US\".*|\\1|p')\"\n\n    case \"$episode_link\" in\n        *repackager.wixmp.com*)\n            extract_link=$(printf \"%s\" \"$episode_link\" | cut -d'>' -f2 | sed 's|repackager.wixmp.com/||g;s|\\.urlset.*||g')\n            for j in $(printf \"%s\" \"$episode_link\" | sed -nE 's|.*/,([^/]*),/mp4.*|\\1|p' | sed 's|,|\\\n|g'); do\n                printf \"%s >%s\\n\" \"$j\" \"$extract_link\" | sed \"s|,[^/]*|${j}|g\"\n            done | sort -nr\n            ;;\n        *master.m3u8*)\n            m3u8_refr=$(printf '%s' \"$response\" | sed -nE 's|.*Referer\":\"([^\"]*)\".*|\\1|p') && printf '%s\\n' \"m3u8_refr >$m3u8_refr\" >\"$cache_dir/m3u8_refr\"\n            extract_link=$(printf \"%s\" \"$episode_link\" | head -1 | cut -d'>' -f2)\n            relative_link=$(printf \"%s\" \"$extract_link\" | sed 's|[^/]*$||')\n            m3u8_streams=\"$(curl -e \"$m3u8_refr\" -s \"$extract_link\" -A \"$agent\")\"\n            printf \"%s\" \"$m3u8_streams\" | grep -q \"EXTM3U\" && printf \"%s\" \"$m3u8_streams\" | sed 's|^#EXT-X-STREAM.*x||g; s|,.*|p|g; /^#/d; $!N; s|\\n| >|;/EXT-X-I-FRAME/d' |\n                sed \"s|>|cc>${relative_link}|g\" | sort -nr\n            printf '%s' \"$response\" | sed -nE 's|.*\"subtitles\":\\[\\{\"lang\":\"en\",\"label\":\"English\",\"default\":\"default\",\"src\":\"([^\"]*)\".*|subtitle >\\1|p' >\"$cache_dir/suburl\"\n            ;;\n        *) [ -n \"$episode_link\" ] && printf \"%s\\n\" \"$episode_link\" ;;\n    esac\n\n    printf \"%s\" \"$*\" | grep -q \"tools.fast4speed.rsvp\" && printf \"%s\\n\" \"Yt >$*\"\n    printf \"\\033[1;32m%s\\033[0m Links Fetched\\n\" \"$provider_name\" 1>&2\n}\n\n# initialises provider_name and provider_id. First argument is the provider name, 2nd is the regex that matches that provider's link\nprovider_init() {\n    provider_name=$1\n    provider_id=$(printf \"%s\" \"$resp\" | sed -n \"$2\" | head -1 | cut -d':' -f2 | sed 's/../&\\\n/g' | sed 's/^79$/A/g;s/^7a$/B/g;s/^7b$/C/g;s/^7c$/D/g;s/^7d$/E/g;s/^7e$/F/g;s/^7f$/G/g;s/^70$/H/g;s/^71$/I/g;s/^72$/J/g;s/^73$/K/g;s/^74$/L/g;s/^75$/M/g;s/^76$/N/g;s/^77$/O/g;s/^68$/P/g;s/^69$/Q/g;s/^6a$/R/g;s/^6b$/S/g;s/^6c$/T/g;s/^6d$/U/g;s/^6e$/V/g;s/^6f$/W/g;s/^60$/X/g;s/^61$/Y/g;s/^62$/Z/g;s/^59$/a/g;s/^5a$/b/g;s/^5b$/c/g;s/^5c$/d/g;s/^5d$/e/g;s/^5e$/f/g;s/^5f$/g/g;s/^50$/h/g;s/^51$/i/g;s/^52$/j/g;s/^53$/k/g;s/^54$/l/g;s/^55$/m/g;s/^56$/n/g;s/^57$/o/g;s/^48$/p/g;s/^49$/q/g;s/^4a$/r/g;s/^4b$/s/g;s/^4c$/t/g;s/^4d$/u/g;s/^4e$/v/g;s/^4f$/w/g;s/^40$/x/g;s/^41$/y/g;s/^42$/z/g;s/^08$/0/g;s/^09$/1/g;s/^0a$/2/g;s/^0b$/3/g;s/^0c$/4/g;s/^0d$/5/g;s/^0e$/6/g;s/^0f$/7/g;s/^00$/8/g;s/^01$/9/g;s/^15$/-/g;s/^16$/./g;s/^67$/_/g;s/^46$/~/g;s/^02$/:/g;s/^17$/\\//g;s/^07$/?/g;s/^1b$/#/g;s/^63$/\\[/g;s/^65$/\\]/g;s/^78$/@/g;s/^19$/!/g;s/^1c$/$/g;s/^1e$/&/g;s/^10$/\\(/g;s/^11$/\\)/g;s/^12$/*/g;s/^13$/+/g;s/^14$/,/g;s/^03$/;/g;s/^05$/=/g;s/^1d$/%/g' | tr -d '\\n' | sed \"s/\\/clock/\\/clock\\.json/\")\n}\n\n# generates links based on given provider\ngenerate_link() {\n    case $1 in\n        1) provider_init \"wixmp\" \"/Default :/p\" ;;    # wixmp(default)(m3u8)(multi) -> (mp4)(multi)\n        2) provider_init \"youtube\" \"/Yt-mp4 :/p\" ;;   # youtube(mp4)(single)\n        3) provider_init \"sharepoint\" \"/S-mp4 :/p\" ;; # sharepoint(mp4)(single)\n        *) provider_init \"hianime\" \"/Luf-Mp4 :/p\" ;;  # hianime(m3u8)(multi)\n    esac\n    [ -n \"$provider_id\" ] && get_links \"$provider_id\"\n}\n\nselect_quality() {\n    # removing urls which have soft subs to avoid playing on android, iSH and vlc (m3u8 streams don't get correct referrer)\n    printf '%s' \"$player_function\" | cut -f1 -d\" \" | grep -qE '(android|iSH|vlc)' && links=$(printf '%s' \"$links\" | sed '/cc>/d;/subtitle >/d;/m3u8_refr >/d')\n    printf '%s' \"$player_function\" | cut -f1 -d\" \" | grep -qE '(android|iSH)' && links=$(printf '%s' \"$links\" | sed '/Yt >/d')\n    case \"$1\" in\n        best) result=$(printf \"%s\" \"$links\" | head -n1) ;;\n        worst) result=$(printf \"%s\" \"$links\" | grep -E '^[0-9]{3,4}' | tail -n1) ;;\n        *) result=$(printf \"%s\" \"$links\" | grep -m 1 \"$1\") ;;\n    esac\n    [ -z \"$result\" ] && printf \"Specified quality not found, defaulting to best\\n\" 1>&2 && result=$(printf \"%s\" \"$links\" | head -n1)\n\n    # add refr,sub flags for m3u8 and refr flag for yt\n    printf '%s' \"$result\" | grep -q \"cc>\" && subtitle=\"$(printf '%s' \"$links\" | sed -nE 's|subtitle >(.*)|\\1|p')\" &&\n        [ -n \"$subtitle\" ] && subs_flag=\"--sub-file=$subtitle\"\n    printf '%s' \"$result\" | grep -q \"cc>\" && m3u8_refr=\"$(printf '%s' \"$links\" | sed -nE 's|m3u8_refr >(.*)|\\1|p')\" && refr_flag=\"--referrer=$m3u8_refr\"\n    printf \"%s\" \"$result\" | grep -q \"tools.fast4speed.rsvp\" && refr_flag=\"--referrer=$allanime_refr\"\n\n    ! (printf '%s' \"$result\" | grep -qE \"(cc>|tools.fast4speed.rsvp)\") && unset refr_flag\n    ! (printf '%s' \"$result\" | grep -q \"cc>\") && unset subs_flag\n    episode=$(printf \"%s\" \"$result\" | cut -d'>' -f2)\n}\n\n# gets embed urls, collects direct links into provider files, selects one with desired quality into $episode\nget_episode_url() {\n    # get the embed urls of the selected episode\n    #shellcheck disable=SC2016\n    episode_embed_gql='query ($showId: String!, $translationType: VaildTranslationTypeEnumType!, $episodeString: String!) { episode( showId: $showId translationType: $translationType episodeString: $episodeString ) { episodeString sourceUrls }}'\n\n    resp=$(curl -e \"$allanime_refr\" -s -G \"${allanime_api}/api\" --data-urlencode \"variables={\\\"showId\\\":\\\"$id\\\",\\\"translationType\\\":\\\"$mode\\\",\\\"episodeString\\\":\\\"$ep_no\\\"}\" --data-urlencode \"query=$episode_embed_gql\" -A \"$agent\" | tr '{}' '\\n' | sed 's|\\\\u002F|\\/|g;s|\\\\||g' | sed -nE 's|.*sourceUrl\":\"--([^\"]*)\".*sourceName\":\"([^\"]*)\".*|\\2 :\\1|p')\n    # generate links into sequential files\n    cache_dir=\"$(mktemp -d)\"\n    providers=\"1 2 3 4\"\n    for provider in $providers; do\n        generate_link \"$provider\" >\"$cache_dir\"/\"$provider\" &\n    done\n    wait\n    # select the link with matching quality\n    links=$(cat \"$cache_dir\"/* | sort -g -r -s)\n    rm -r \"$cache_dir\"\n    select_quality \"$quality\"\n    if printf \"%s\" \"$ep_list\" | grep -q \"^$ep_no$\"; then\n        [ -z \"$episode\" ] && die \"Episode is released, but no valid sources!\"\n    else\n        [ -z \"$episode\" ] && die \"Episode not released!\"\n    fi\n}\n\n# search the query and give results\nsearch_anime() {\n    #shellcheck disable=SC2016\n    search_gql='query( $search: SearchInput $limit: Int $page: Int $translationType: VaildTranslationTypeEnumType $countryOrigin: VaildCountryOriginEnumType ) { shows( search: $search limit: $limit page: $page translationType: $translationType countryOrigin: $countryOrigin ) { edges { _id name availableEpisodes __typename } }}'\n\n    curl -e \"$allanime_refr\" -s -G \"${allanime_api}/api\" --data-urlencode \"variables={\\\"search\\\":{\\\"allowAdult\\\":false,\\\"allowUnknown\\\":false,\\\"query\\\":\\\"$1\\\"},\\\"limit\\\":40,\\\"page\\\":1,\\\"translationType\\\":\\\"$mode\\\",\\\"countryOrigin\\\":\\\"ALL\\\"}\" --data-urlencode \"query=$search_gql\" -A \"$agent\" | sed 's|Show|\\\n| g' | sed -nE \"s|.*_id\\\":\\\"([^\\\"]*)\\\",\\\"name\\\":\\\"(.+)\\\",.*${mode}\\\":([1-9][^,]*).*|\\1\t\\2 (\\3 episodes)|p\" | sed 's/\\\\\"//g'\n}\n\ntime_until_next_ep() {\n    animeschedule=\"https://animeschedule.net\"\n    query=\"$(printf \"%s\\n\" \"$*\" | tr ' ' '+')\"\n    curl -s -G \"$animeschedule/api/v3/anime\" --data \"q=${query}\" | sed 's|\"id\"|\\n|g' | sed -nE 's|.*,\"route\":\"([^\"]*)\",\"premier.*|\\1|p' | while read -r anime; do\n        data=$(curl -s \"$animeschedule/anime/$anime\" | sed '1,/\"anime-header-list-buttons-wrapper\"/d' | sed -nE 's|.*countdown-time-raw\" datetime=\"([^\"]*)\">.*|Next Raw Release: \\1|p;s|.*countdown-time\" datetime=\"([^\"]*)\">.*|Next Sub Release: \\1|p;s|.*english-title\">([^<]*)<.*|English Title: \\1|p;s|.*main-title\".*>([^<]*)<.*|Japanese Title: \\1|p')\n        status=\"Ongoing\"\n        color=\"33\"\n        printf \"%s\\n\" \"$data\"\n        ! (printf \"%s\\n\" \"$data\" | grep -q \"Next Raw Release:\") && status=\"Finished\" && color=\"32\"\n        printf \"Status:  \\033[1;%sm%s\\033[0m\\n---\\n\" \"$color\" \"$status\"\n    done\n    exit 0\n}\n\n# get the episodes list of the selected anime\nepisodes_list() {\n    #shellcheck disable=SC2016\n    episodes_list_gql='query ($showId: String!) { show( _id: $showId ) { _id availableEpisodesDetail }}'\n\n    curl -e \"$allanime_refr\" -s -G \"${allanime_api}/api\" --data-urlencode \"variables={\\\"showId\\\":\\\"$*\\\"}\" --data-urlencode \"query=$episodes_list_gql\" -A \"$agent\" | sed -nE \"s|.*$mode\\\":\\[([0-9.\\\",]*)\\].*|\\1|p\" | sed 's|,|\\\n|g; s|\"||g' | sort -n -k 1\n}\n\n# PLAYING\n\nprocess_hist_entry() {\n    ep_list=$(episodes_list \"$id\")\n    latest_ep=$(printf \"%s\\n\" \"$ep_list\" | tail -n1)\n    title=$(printf \"%s\\n\" \"$title\" | sed \"s|[0-9]\\+ episodes|${latest_ep} episodes|\")\n    ep_no=$(printf \"%s\" \"$ep_list\" | sed -n \"/^${ep_no}$/{n;p;}\") 2>/dev/null\n    [ -n \"$ep_no\" ] && printf \"%s\\t%s - episode %s\\n\" \"$id\" \"$title\" \"$ep_no\"\n}\n\nupdate_history() {\n    if grep -q -- \"$id\" \"$histfile\"; then\n        sed -E \"s|^[^\t]+\t${id}\t[^\t]+$|${ep_no}\t${id}\t${title}|\" \"$histfile\" >\"${histfile}.new\"\n    else\n        cp \"$histfile\" \"${histfile}.new\"\n        printf \"%s\\t%s\\t%s\\n\" \"$ep_no\" \"$id\" \"$title\" >>\"${histfile}.new\"\n    fi\n    mv \"${histfile}.new\" \"$histfile\"\n}\n\ndownload() {\n    # download subtitle if it's set\n    [ -n \"$subtitle\" ] && curl -s \"$subtitle\" -o \"$download_dir/$2.vtt\"\n    case $1 in\n        *m3u8*)\n            if command -v \"yt-dlp\" >/dev/null; then\n                yt-dlp --referer \"$m3u8_refr\" \"$1\" --no-skip-unavailable-fragments --fragment-retries infinite -N 16 -o \"$download_dir/$2.mp4\"\n            else\n                ffmpeg -extension_picky 0 -referer \"$m3u8_refr\" -loglevel error -stats -i \"$1\" -c copy \"$download_dir/$2.mp4\"\n            fi\n            # embed subs into downloads\n            # [ -e \"$download_dir/$2.vtt\" ] && ffmpeg -i \"$download_dir/$2.mp4\" -i \"$download_dir/$2.vtt\" -c copy -c:s mov_text \"$download_dir/$2.bak.mp4\" && mv \"$download_dir/$2.bak.mp4\" \"$download_dir/$2.mp4\"\n            ;;\n        *)\n            # shellcheck disable=SC2086\n            aria2c --referer=\"$allanime_refr\" --enable-rpc=false --check-certificate=false --continue $iSH_DownFix --summary-interval=0 -x 16 -s 16 \"$1\" --dir=\"$download_dir\" -o \"$2.mp4\" --download-result=hide\n            ;;\n    esac\n}\n\nplay_episode() {\n    [ \"$log_episode\" = 1 ] && [ \"$player_function\" != \"debug\" ] && [ \"$player_function\" != \"download\" ] && command -v logger >/dev/null && logger -t ani-cli \"${allanime_title}${ep_no}\"\n    [ \"$skip_intro\" = 1 ] && skip_flag=\"$(ani-skip -q \"$mal_id\" -e \"$ep_no\")\"\n    [ -z \"$episode\" ] && get_episode_url\n    # shellcheck disable=SC2086\n    case \"$player_function\" in\n        debug)\n            printf \"All links:\\n%s\\nSelected link:\\n\" \"$links\"\n            printf \"%s\\n\" \"$episode\"\n            ;;\n        mpv*)\n            if [ \"$no_detach\" = 0 ]; then\n                nohup $player_function $skip_flag --force-media-title=\"${allanime_title}Episode ${ep_no}\" \"$episode\" $subs_flag $refr_flag >/dev/null 2>&1 &\n            else\n                $player_function $skip_flag $subs_flag $refr_flag --force-media-title=\"${allanime_title}Episode ${ep_no}\" \"$episode\"\n                mpv_exitcode=$?\n                [ \"$exit_after_play\" = 1 ] && [ -z \"$range\" ] && exit \"$mpv_exitcode\"\n            fi\n            ;;\n        android_mpv) nohup am start --user 0 -a android.intent.action.VIEW -d \"$episode\" -n is.xyz.mpv/.MPVActivity >/dev/null 2>&1 & ;;\n        android_vlc) nohup am start --user 0 -a android.intent.action.VIEW -d \"$episode\" -n org.videolan.vlc/org.videolan.vlc.gui.video.VideoPlayerActivity -e \"title\" \"${allanime_title}Episode ${ep_no}\" >/dev/null 2>&1 & ;;\n        *iina*)\n            [ -n \"$subs_flag\" ] && subs_flag=\"--mpv-${subs_flag#--}\"\n            [ -n \"$refr_flag\" ] && refr_flag=\"--mpv-${refr_flag#--}\"\n            if pgrep -f \"IINA\" >/dev/null 2>&1; then\n                # omit --keep-running when an IINA instance exists to prevent hanging\n                nohup $player_function --no-stdin --mpv-force-media-title=\"${allanime_title}Episode ${ep_no}\" $subs_flag $refr_flag \"$episode\" >/dev/null 2>&1 &\n            else\n                nohup $player_function --no-stdin --keep-running --mpv-force-media-title=\"${allanime_title}Episode ${ep_no}\" $subs_flag $refr_flag \"$episode\" >/dev/null 2>&1 &\n            fi\n            ;;\n        flatpak_mpv) flatpak run io.mpv.Mpv --force-media-title=\"${allanime_title}Episode ${ep_no}\" \"$episode\" $subs_flag $refr_flag >/dev/null 2>&1 & ;;\n        vlc*) nohup $player_function --http-referrer=\"${allanime_refr}\" --play-and-exit --meta-title=\"${allanime_title}Episode ${ep_no}\" \"$episode\" >/dev/null 2>&1 & ;;\n        *yncpla*) nohup $player_function \"$episode\" -- --force-media-title=\"${allanime_title}Episode ${ep_no}\" $subs_flag $refr_flag >/dev/null 2>&1 & ;;\n        download) \"$player_function\" \"$episode\" \"${allanime_title}Episode ${ep_no}\" \"$subtitle\" ;;\n        catt) nohup catt cast \"$episode\" -s \"$subtitle\" >/dev/null 2>&1 & ;;\n        iSH)\n            printf \"\\e]8;;vlc://%s\\a~~~~~~~~~~~~~~~~~~~~\\n~ Tap to open VLC ~\\n~~~~~~~~~~~~~~~~~~~~\\e]8;;\\a\\n\" \"$episode\"\n            sleep 5\n            ;;\n        *) nohup $player_function \"$episode\" >/dev/null 2>&1 & ;;\n    esac\n    replay=\"$episode\"\n    unset episode\n    update_history\n    [ \"$use_external_menu\" = \"1\" ] && wait\n    [ \"$use_external_menu\" = \"2\" ] && wait\n}\n\nplay() {\n    start=$(printf \"%s\" \"$ep_no\" | grep -Eo '^(-1|[0-9]+(\\.[0-9]+)?)')\n    end=$(printf \"%s\" \"$ep_no\" | grep -Eo '(-1|[0-9]+(\\.[0-9]+)?)$')\n    [ \"$start\" = \"-1\" ] && ep_no=$(printf \"%s\" \"$ep_list\" | tail -n1) && unset start\n    [ -z \"$end\" ] || [ \"$end\" = \"$start\" ] && unset start end\n    [ \"$end\" = \"-1\" ] && end=$(printf \"%s\" \"$ep_list\" | tail -n1)\n    line_count=$(printf \"%s\\n\" \"$ep_no\" | wc -l | tr -d \"[:space:]\")\n    if [ \"$line_count\" != 1 ] || [ -n \"$start\" ]; then\n        [ -z \"$start\" ] && start=$(printf \"%s\\n\" \"$ep_no\" | head -n1)\n        [ -z \"$end\" ] && end=$(printf \"%s\\n\" \"$ep_no\" | tail -n1)\n        range=$(printf \"%s\\n\" \"$ep_list\" | sed -nE \"/^${start}\\$/,/^${end}\\$/p\")\n        [ -z \"$range\" ] && die \"Invalid range!\"\n        for i in $range; do\n            tput clear\n            ep_no=$i\n            printf \"\\33[2K\\r\\033[1;34mPlaying episode %s...\\033[0m\\n\" \"$ep_no\"\n            [ \"$i\" = \"$end\" ] && unset range\n            play_episode\n        done\n    else\n        play_episode\n    fi\n    # moves up to stored position and deletes to end\n    [ \"$player_function\" != \"debug\" ] && [ \"$player_function\" != \"download\" ] && tput rc && tput ed\n}\n\n# MAIN\n\n# setup\nagent=\"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/121.0\"\nallanime_refr=\"https://allmanga.to\"\nallanime_base=\"allanime.day\"\nallanime_api=\"https://api.${allanime_base}\"\nmode=\"${ANI_CLI_MODE:-sub}\"\ndownload_dir=\"${ANI_CLI_DOWNLOAD_DIR:-.}\"\nlog_episode=\"${ANI_CLI_LOG:-1}\"\nquality=\"${ANI_CLI_QUALITY:-best}\"\ncase \"$(uname -a | cut -d \" \" -f 1,3-)\" in\n    *Darwin*) player_function=\"${ANI_CLI_PLAYER:-$(where_iina)}\" ;;   # mac OS\n    *ndroid*) player_function=\"${ANI_CLI_PLAYER:-android_mpv}\" ;;     # Android OS (termux)\n    *MINGW* | *WSL2*) player_function=\"${ANI_CLI_PLAYER:-mpv.exe}\" ;; # Windows OS\n    *ish*) player_function=\"${ANI_CLI_PLAYER:-iSH}\" ;;                # iOS (iSH)\n    *) player_function=\"${ANI_CLI_PLAYER:-$(where_mpv)}\" ;;           # Linux OS\nesac\n\nno_detach=\"${ANI_CLI_NO_DETACH:-0}\"\nexit_after_play=\"${ANI_CLI_EXIT_AFTER_PLAY:-0}\"\nuse_external_menu=\"${ANI_CLI_EXTERNAL_MENU:-0}\"\nexternal_menu_normal_window=\"${ANI_CLI_EXTERNAL_MENU_NORMAL_WINDOW:-0}\"\nskip_intro=\"${ANI_CLI_SKIP_INTRO:-0}\"\n# shellcheck disable=SC2154\nskip_title=\"$ANI_CLI_SKIP_TITLE\"\n[ -t 0 ] || (command -v dmenu && use_external_menu=2)\n[ -t 0 ] || (command -v rofi && use_external_menu=1)\nhist_dir=\"${ANI_CLI_HIST_DIR:-${XDG_STATE_HOME:-$HOME/.local/state}/ani-cli}\"\n[ ! -d \"$hist_dir\" ] && mkdir -p \"$hist_dir\"\nhistfile=\"$hist_dir/ani-hsts\"\n[ ! -f \"$histfile\" ] && : >\"$histfile\"\nsearch=\"${ANI_CLI_DEFAULT_SOURCE:-scrape}\"\n\nwhile [ $# -gt 0 ]; do\n    case \"$1\" in\n        -v | --vlc)\n            case \"$(uname -a | cut -d \" \" -f 1,3-)\" in\n                *ndroid*) player_function=\"android_vlc\" ;;\n                MINGW* | *WSL2*) player_function=\"vlc.exe\" ;;\n                *ish*) player_function=\"iSH\" ;;\n                *) player_function=\"vlc\" ;;\n            esac\n            ;;\n        -s | --syncplay)\n            case \"$(uname -s)\" in\n                Darwin*) player_function=\"/Applications/Syncplay.app/Contents/MacOS/syncplay\" ;;\n                MINGW* | *Msys)\n                    export PATH=\"$PATH\":\"/c/Program Files (x86)/Syncplay/\"\n                    player_function=\"syncplay.exe\"\n                    ;;\n                *) player_function=\"syncplay\" ;;\n            esac\n            ;;\n        -q | --quality)\n            [ $# -lt 2 ] && die \"missing argument!\"\n            quality=\"$2\"\n            shift\n            ;;\n        -S | --select-nth)\n            [ $# -lt 2 ] && die \"missing argument!\"\n            index=\"$2\"\n            shift\n            ;;\n        -c | --continue) search=history ;;\n        -d | --download)\n            [ \"$player_function\" = \"iSH\" ] && iSH_DownFix=\"--async-dns=false\"\n            player_function=download\n            ;;\n        -D | --delete)\n            : >\"$histfile\"\n            exit 0\n            ;;\n        -l | --logview)\n            case \"$(uname -s)\" in\n                Darwin*) log show --predicate 'process == \"logger\"' ;;\n                Linux*) journalctl -t ani-cli ;;\n                *) die \"Logger not implemented for your platform\" ;;\n            esac\n            exit 0\n            ;;\n        -V | --version) version_info ;;\n        -h | --help) help_info ;;\n        -e | --episode | -r | --range)\n            [ $# -lt 2 ] && die \"missing argument!\"\n            ep_no=\"$2\"\n            shift\n            ;;\n        --dub) mode=\"dub\" ;;\n        --no-detach) no_detach=1 ;;\n        --exit-after-play) exit_after_play=1 && no_detach=1 ;;\n        --rofi) use_external_menu=1 ;;\n        --dmenu) use_external_menu=2 ;;\n        --skip) skip_intro=1 ;;\n        --skip-title)\n            [ $# -lt 2 ] && die \"missing argument!\"\n            skip_title=\"$2\"\n            shift\n            ;;\n        -N | --nextep-countdown) search=nextep ;;\n        -U | --update) update_script ;;\n        *) query=\"$(printf \"%s\" \"$query $1\" | sed \"s|^ ||;s| |+|g\")\" ;;\n    esac\n    shift\ndone\n[ \"$use_external_menu\" = \"0\" ] && multi_selection_flag=\"${ANI_CLI_MULTI_SELECTION:-\"-m\"}\"\n[ \"$use_external_menu\" = \"1\" ] && multi_selection_flag=\"${ANI_CLI_MULTI_SELECTION:-\"-multi-select\"}\"\n[ \"$external_menu_normal_window\" = \"1\" ] && external_menu_args=\"-normal-window\"\nprintf \"\\33[2K\\r\\033[1;34mChecking dependencies...\\033[0m\\n\"\ndep_ch \"curl\" \"sed\" \"grep\" || true\n[ \"$skip_intro\" = 1 ] && (dep_ch \"ani-skip\" || true)\ndep_ch \"fzf\" || true\ncase \"$player_function\" in\n    debug) ;;\n    download) dep_ch \"ffmpeg\" \"aria2c\" ;;\n    android*) printf \"\\33[2K\\rChecking of players on Android is disabled\\n\" ;;\n    *iSH*) printf \"\\33[2K\\rChecking of players on iOS is disabled\\n\" ;;\n    flatpak_mpv) true ;; # handled out of band in where_mpv\n    *) dep_ch \"$player_function\" ;;\nesac\n\n# searching\ncase \"$search\" in\n    history)\n        anime_list=$(while read -r ep_no id title; do process_hist_entry & done <\"$histfile\")\n        wait\n        [ -z \"$anime_list\" ] && die \"No unwatched series in history!\"\n        [ -z \"${index##*[!0-9]*}\" ] && id=$(printf \"%s\" \"$anime_list\" | nl -w 2 | sed 's/^[[:space:]]//' | nth \"Select anime: \" | cut -f1)\n        [ -z \"${index##*[!0-9]*}\" ] || id=$(printf \"%s\" \"$anime_list\" | sed -n \"${index}p\" | cut -f1)\n        [ -z \"$id\" ] && exit 1\n        title=$(printf \"%s\" \"$anime_list\" | grep \"$id\" | cut -f2 | sed 's/ - episode.*//')\n        ep_list=$(episodes_list \"$id\")\n        ep_no=$(printf \"%s\" \"$anime_list\" | grep \"$id\" | cut -f2 | sed -nE 's/.*- episode (.+)$/\\1/p')\n        allanime_title=\"$(printf \"%s\" \"$title\" | cut -d'(' -f1 | tr -d '[:punct:]')\"\n        ;;\n    *)\n        if [ \"$use_external_menu\" = \"0\" ]; then\n            while [ -z \"$query\" ]; do\n                printf \"\\33[2K\\r\\033[1;36mSearch anime: \\033[0m\" && read -r query\n            done\n        else\n            [ -z \"$query\" ] && query=$(printf \"\" | external_menu \"\" \"Search anime: \" \"$external_menu_args\")\n            [ -z \"$query\" ] && exit 1\n        fi\n        # for checking new releases by specifying anime name\n        [ \"$search\" = \"nextep\" ] && time_until_next_ep \"$query\"\n\n        query=$(printf \"%s\" \"$query\" | sed \"s| |+|g\")\n        anime_list=$(search_anime \"$query\")\n        [ -z \"$anime_list\" ] && die \"No results found!\"\n        [ \"$index\" -eq \"$index\" ] 2>/dev/null && result=$(printf \"%s\" \"$anime_list\" | sed -n \"${index}p\")\n        [ -z \"$index\" ] && result=$(printf \"%s\" \"$anime_list\" | nl -w 2 | sed 's/^[[:space:]]//' | nth \"Select anime: \")\n        [ -z \"$result\" ] && exit 1\n        title=$(printf \"%s\" \"$result\" | cut -f2)\n        allanime_title=\"$(printf \"%s\" \"$title\" | cut -d'(' -f1 | tr -d '[:punct:]')\"\n        id=$(printf \"%s\" \"$result\" | cut -f1)\n        ep_list=$(episodes_list \"$id\")\n        [ -z \"$ep_no\" ] && ep_no=$(printf \"%s\" \"$ep_list\" | nth \"Select episode: \" \"$multi_selection_flag\")\n        [ -z \"$ep_no\" ] && exit 1\n        ;;\nesac\n[ \"$skip_intro\" = 1 ] && mal_id=\"$(ani-skip -q \"${skip_title:-${title}}\")\"\n\n# moves the cursor up one line and clears that line\ntput cuu1 && tput el\n# stores the position of cursor\ntput sc\n\n# playback & loop\nplay\n[ \"$player_function\" = \"download\" ] || [ \"$player_function\" = \"debug\" ] && exit 0\n\nwhile cmd=$(printf \"next\\nreplay\\nprevious\\nselect\\nchange_quality\\nquit\" | nth \"Playing episode $ep_no of $title... \"); do\n    case \"$cmd\" in\n        next) ep_no=$(printf \"%s\" \"$ep_list\" | sed -n \"/^${ep_no}$/{n;p;}\") 2>/dev/null ;;\n        replay) episode=\"$replay\" ;;\n        previous) ep_no=$(printf \"%s\" \"$ep_list\" | sed -n \"/^${ep_no}$/{g;1!p;};h\") 2>/dev/null ;;\n        select) ep_no=$(printf \"%s\" \"$ep_list\" | nth \"Select episode: \" \"$multi_selection_flag\") ;;\n        change_quality)\n            new_quality=\"$(printf \"%s\" \"$links\" | launcher | cut -d\\> -f1)\"\n            select_quality \"$new_quality\"\n            ;;\n        *) exit 0 ;;\n    esac\n    [ -z \"$ep_no\" ] && die \"Out of range\"\n    play\ndone\n\n# ani-cli\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program. If not, see <http://www.gnu.org/licenses/>.\n#\n# Project repository: https://github.com/pystardust/ani-cli\n"
  },
  {
    "path": "ani-cli.1",
    "content": ".TH \"ANI-CLI\" \"1\" \"January 2023\" \"ani-cli\" \"User Commands\"\n.SH NAME\nani-cli \\- watch anime from the commandline\n.SH SYNOPSIS\n.B ani-cli\n[\\fI\\,OPTIONS\\/\\fR]\n.SH DESCRIPTION\nA shell script to browse and search anime from the command-line.\n.PD 0\n.P\n.PD\nThis tool scrapes the site allanime.\n.PD 0\n.P\n.PD\n\\f[B]ani-cli\\f[R] without options defaults to iina on macOS, flatpak mpv on Steamdeck, mpv apk on android, vlc on iOS and mpv media player everywhere else.\n.SH OPTIONS\n.TP\n\\fB\\-e | --episode | -r | --range\\fR \\fI\\,<episode>\\/\\fR\nSpecify the episode numbers to watch. If range is specified it should be quoted or separated by a non-numeric character (eg. -).\n.TP\n\\fB\\-c | --continue\\fR\nContinue watching anime from history.\n.TP\n\\fB\\-d | --download\\fR\nDownload episode.\n.TP\n\\fB\\-D | --delete\\fR\nDelete history.\n.TP\n\\fB\\-l | --logview\\fR\nShow logs.\n.TP\n\\fB\\-h | --help\\fR\nShow summary of options.\n.TP\n\\fB\\-q | --quality\\fR \\fI\\,<best|worst|360|480|720|1080>\\/\\fR\nSet the video quality. Default quality is best.\n.TP\n\\fB\\-s | --syncplay\\fR\nWatch anime together with friends, using Syncplay (works with mpv only).\n.TP\n\\fB\\-U | --update\\fR\nFetch update from github.\n.TP\n\\fB\\-v | --vlc\\fR\nUse VLC as the media player.\n.TP\n\\fB\\-S | --select-nth\\fR \\fI\\,<index>\\/\\fR\nSelects nth entry.\n.TP\n\\fB\\-N | --nextep-countdown\\fR\nPrints a countdown to the next episode as the last episode in the list. If in history is after the current episode.\n.TP\n\\fB\\--dub\\fR\nPlay the dubbed version. Without this flag, it'll always play the subbed version.\n.TP\n\\fB\\--rofi\\fR\nUse rofi instead of fzf for the interactive menu\n.TP\n\\fB\\--skip\\fR\nUse ani-skip to skip the intro of the episode (mpv only)\n.TP\n\\fB\\--no-detach\\fR\nDon't detach the player (useful for in-terminal playback, mpv only)\n.TP\n\\fB\\--exit-after-play\\fR\nExit the player, and return the player exit code (useful for non interactive scenarios, mpv only)\n.TP\n\\fB\\--skip-title\\fR \\fI\\,<title>\\/\\fR\nSpecify the title to use for ani-skip\n.PP\n.SH\nENVIRONMENT VARIABLES\n.PP\nani-cli v4 uses environment variables to control unstable/untested and niche features in addition to everything that has an option. Command-line options take precedence over env vars. Note that these are all subject to change.\n.TP\n\\fBANI_CLI_MODE\\fR\nControls the scraped media's mode, valid options are sub or dub. Default is sub.\n.TP\n\\fBANI_CLI_DOWNLOAD_DIR\\fR\nControls the directory where files are downloaded. Default is the current dir.\n.TP\n\\fBANI_CLI_QUALITY\\fR\nControls the scraped media's quality, check allanime for valid options or set to worst/best. Default is best.\n.TP\n\\fBANI_CLI_PLAYER\\fR\nSets the player ani-cli uses. Can be debug (print links), download (equivalent to -d), android_mpv (apk and am start), android_vlc (apk and am start), flatpak_mpv (for flatpak), catt (for streaming to tv), or any player that can play urls. For defaults see working without arguments.\n.TP\n\\fBANI_CLI_EXTERNAL_MENU\\fR\nControls the frontend of ani-cli. Can be 0 (uses fzf) or 1 (uses rofi dmenu). Default is 0.\n.TP\n\\fBANI_CLI_EXTERNAL_MENU_NORMAL_WINDOW\\fR\nControls the way rofi displays the window. Can be 0 (no additional arguments passed to rofi) or 1 (the menu is displayed as a normal window, -normal-window argument is passed to rofi). Default is 0.\n.TP\n\\fBANI_CLI_LOG_EPISODE\\fR\nControls the logging feature for playback. Can be 1(logs) or 0(doesn't log). Default is 1.\n.TP\n\\fBANI_CLI_MULTI_SELECTION\\fR\nControls the multi flag for the chosen frontend. Default is -m for fzf and --multi-select for rofi dmenu.\n.TP\n\\fBANI_CLI_HIST_DIR\\fR\nControls the directory ani-cli uses for storing history. A /ani-cli subfolder is created there for the histfile if doesn't exists. Default is $XDG_STATE_HOME if set, $HOME/.local/state if not.\n.TP\n\\fBANI_CLI_DEFAULT_SOURCE\\fR\nControls the default source. Valid is history (equivalent to -c), everything else means search. Default is search.\n.TP\n\\fBANI_CLI_SKIP_INTRO\\fR\nControls if ani-skip is used to skip intros (works with mpv only). Can be 0 (disabled) or 1 (enabled). Default is 0.\n.TP\n\\fBANI_CLI_NO_DETACH\\fR\nControls if mpv is detached from the main process for playback, which can be useful for use with terminal renderers such as kitty. (works with mpv only). Can be 0 (disabled) or 1 (enabled). Default is 0.\n.TP\n\\fBANI_CLI_SKIP_TITLE\\fR\nOverrides the anime title to query for skip times. Can be any string value. Default is empty, resolving to the anime title as given by ani-cli.\n.PP\n.SH EPISODE SELECTION\n.PP\nMultiple episodes can be chosen using fzf (or alternative frontend's) multi-selection mode. For this refer to their instructions.\n.SH BUGS\n.PP\nUse the GitHub issue tracker:\nhttps://github.com/pystardust/ani-cli/issues\n.SH COPYRIGHT\n.PP\nani-cli is licensed under the GNU General Public License v3.0\n.PP\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n.PP\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n.PP\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see <http://www.gnu.org/licenses/>.\n"
  },
  {
    "path": "disclaimer.md",
    "content": "\n<h1 align=\"center\">Disclaimer</h1>\n\n<div align=\"center\">\n\n<h2>This project: ani-cli</h2>\n\n<br>\n\nThe core aim of this project is to co-relate automation and efficiency to extract what is provided to a user on the internet. All content available through the project is hosted by external non-affiliated sources.\n\n<br>\n\n<b>Any content served through this project is publicly accessible. If your site is listed in this project, the code is pretty much public. Take necessary measures to counter the exploits used to extract content in your site.</b>\n\nThink of this project as your normal browser, but a bit more straight-forward and specific. While an average browser makes hundreds of requests to get everything from a site, this project goes on to make requests associated with only getting the content served by the sites.\n\n<b>\n\nThis project is to be used at the user's own risk, based on their government and laws.\n\nThis project has no control on the content it is serving, using copyrighted content from the providers is not going to be accounted for by the developer. It is the user's own risk.\n\n</b>\n\n<br>\n\n<h2>DMCA and Copyright Infrigements</h3>\n\n<br>\n\n<b>\nA browser is a tool, and the maliciousness of the tool is directly based on the user.\n</b>\n\nThis project uses client-side content access mechanisms. Hence, the copyright infrigements or DMCA in this project's regards are to be forwarded to the associated site by the associated notifier of any such claims. As of writing this is [allanime](https://allanime.to)\n\n<b> Do not harass the maintainer. </b>\n\n<h2>\nContacting the maintainer\n</h2>\n<br>\n\nBegin by making a GitHub issue or sending an email to port19@port19.xyz\n</div>\n"
  },
  {
    "path": "hacking.md",
    "content": "# Hacking ani-cli\nAni-cli is set up to scrape one platform - currently allanime. Supporting multiple sources at a time would require more changes than we (the maintainers) find worth doing, for this reason any feature request asking for a new site is rejected.\n\nHowever ani-cli being open-source and the pirate anime streaming sites being so similar you can hack ani-cli to support any site that follows a few conventions.\n\n## Prerequisites\nHere's the of skills you'll need and the guide will take for granted:\n- basic shell scripting\n- understanding of http(s) requests and proficiency with curl\n- ability to read html and javascript on a basic level and search them\n- writing regexes\nYou'll also need web browser with a debugger and environment that can run unmodified ani-cli\n\n## The scraping process\nThe following flowchart demonstrates how ani-cli operates from a scraping standpoint:\n\n![image](.assets/ani-cli-scraping-flow.png)\n\nThe steps to get to a link from a query is the following:\n1. search with the site's search page for the query\n2. extract IDs from response, user chooses one\n3. extract episode numbers from an overview page, user chooses one\n4. download player(s) for that id+episode number combination, extract links\n5. quality selection selects one that is played\nFrom here 1-4 need to be changed to support another site. #Reverse-engineering will answer how.\n\n## Reverse-engineering\nMany sites have various protections against reverse-engineering.\nThe extension webapi-blocker can help you with bringing up the debugger that we'll use during this guide or to conceal the presence of a debugger.\nThese reverse-engineering protections are always evolving though so there's no silver bullet - you'll have to do your own research on how to get around them.\n\nAn adblocker can help with reducing traffic from the site, but beware of extensions that change the appearance of the site (eg. darkreader) because they can alter the html/css.\n\nOnce you have the pages (urls) that you're interested in, it's easier to inspect them from less/an editor.\nThe debugger's inspector can help you with finding what's what but finding patterns/urls is much easier in an editor.\nAdditionally the debugger doesn't always show you the html faithfully - I've experienced some escape sequences being rendered, capitalization changing - so be sure you see the response of the servers in raw format before you write your regexes.\n\n### Core concepts\nIf you navigate the site normally from the browser, you'll see that each anime is represented with an URL that compromises from an ID (that identifies a series/season of series) and an episode number.\nThe series identifier is stored in the `id` variable by the script and the episode number in the `ep_no` number.\n\nEach episode has an embedded player that contains the links to the videos to be played.\nYour goal is to get these links along with the resolution (quality) of the streams.\nThe embedded player has a separate URL from the episode page, but you can always get there from the episode page (and in some cases just by knowing the id and the episode number).\n\n### Searching\nThe search page is usually easy to find on these websites. The searching method varies.\nSome sites will have you post a database query in plaintext, some just use a get request with a single variable.\nJust try searching for a few series and see how the URL changes (most of the times the sites use a get request for this purpose).\nIf the site uses a POST request or a more roundabout way, use the debugger to analyze the traffic.\n\nOnce you figured out how searching works, you'll have to replicate it in the `search_anime` function.\nThe `curl` in this function is responsible for the search request, and the following `sed` regexes mold the response into many lines of `id\\ttitle` format.\nThe reason for this is the `nth` function, see it for more details.\nYou'll have to change some variables in the process (eg. allanime_base) too.\n\nIf you have done everything correctly, you can run `ani-cli`, query your site of choice and select from the responses.\nThen ani-cli should fail without a message.\nIf it fails with `No results found!` you have debugging to do.\nRunning ani-cli with `sh -x` is a good way to debug.\n\n### Episode selection\nHaving completed the previous step, the `id` and `title` will contain the selected title and the corresponding id.\n\nNow you'll have to look at the page where all the episodes of the series are listed.\nThis might be a series overview page (like with allanime) or there might not be such, but the episode pages have links to all episodes.\n\nYou'll have to edit the `episodes_list` function that downloads this list of urls.\nYou need to rewrite the web request and the following regexes to achieve a list of episode numbers separated by newlines and preferably sorted.\nAgain the `nth` function is used to offer a selection.\n\nIf you have done everything correctly, now you can search for a title, get its episodes listed and select an episode.\nThen ani-cli should fail with `Episode not released!`\n\n### Getting the player embed\nAfter selecting an episode, the next step is to load its page and extract the embed(s).\nIn case you can get them without loading the episode page, replace from the `get the embed urls...` part of the code to the removal of the cache dir with a single call to `get_links` and load its output into `links`.\nThen move to the next step (and remove all functions rendered unused).\n\nThe first request is to get the episode page, then the following commands extract the embed players' links, one at a line with the format `sourcename : url`.\nThese are listed into `resp`.\nFrom here they are separated and parsed by `provider_init` and the first half onf `generate_link`.\nSome sites (like allanime) have these urls not in plaintext but \"encrypted\". The decrypt allanime function does this post-processing, it might need to be changed or discarded completely.\n\nIf there's only one embed source, the `generate links..` block can be reduced to a single call to `generate_link`.\nThe current structure does the aggregation of many providers asynchronously, but this is not needed if there's only one source.\n\n### Extracting the media links\n\nOnce you have the embed player, it needs to be parsed for the media link.\nThis is done in the script with the `get_links` function.\n\nHere first the embed player is first requested and loaded into `episode_link` the media links are extracted.\nThey need to be printed to the function's stdout in a format of `quality >link`.\nThe quality string needs to be extracted from the player along with the link and is supposed to be a numeric representation of the resolution.\nSometimes a resolution can't be determined, in this case have the regex match for whatever is in its place.\n\nThe output of the `get_links` function needs to be concatenated into the `links` variable - with a single call if there's only one source, or with the asynchronous mode if there are more.\nFrom here the `get_episode_url` function will continue with quality selection which you need not to alter.\n\n## Other functionality\nAssuming you completed all the necessary modifications, ani-cli should completely work for you now.\nThe UI and the history system works as long as you keep the structure of the original code and the format of the responses.\n\nThere might be cases that can't be covered by the current structure of ani-cli, but still it works for most sites as I've observed.\n\n## UX Spec\n\nThere also exists a UX spec if you want to replicate the ani-cli user experience in a fresh codebase:\n![image](.assets/ani-cli-ux-spec.png)\n"
  },
  {
    "path": "matrix.md",
    "content": "To get invited to ani-cli matrix space please knock into the `#ani-cli-queue:matrix.org` room.\n\nIn the reason field, please mention that you want to be invited to ani-cli.\nIf your main client does not support spaces, please add that to the reason.\n\nKnocking is not supported by every client yet. You can use nheko.\nIn nheko, click on a `plus icon` in the down left corner, `join room`, input `#ani-cli-queue:matrix.org` into the \"Room ID or alias\" input box.\nIt will say that you are not allowed to join and ask if you want to knock.\n\nIt might take some time before you get invited.\n"
  }
]