justfoolingaround / animdl

A highly efficient, fast, powerful and light-weight anime downloader and streamer for your favorite anime.
GNU General Public License v3.0
1.32k stars 109 forks source link
anime download python scraper

A highly efficient, powerful and fast anime scraper.


Overview

Installation

This project can be installed on to your device via different mechanisms, these mechanisms are listed below in the order of ease.

  1. PIP Installs Packages aka PIP Installation

    pip install animdl
  2. Installation from source

    First ensure Poetry is installed.

    Then run the following command:

    git clone https://www.github.com/justfoolingaround/animdl.git \
    && cd animdl \
    && poetry build \
    && pip install animdl \
    && cd ..

Support

You can contact the developer directly via this email. However, the most recommended way is to head to the discord server.

If you run into issues or want to request a new feature, you are encouraged to make a GitHub issue, won't bite you, trust me.

Usage

Usage: animdl [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  download  Download your favorite anime by query.
  grab      Stream the stream links to the stdout stream for external usage.
  schedule  Know which animes are going over the air when.
  search    Search for an anime in the provider.
  stream    Stream your favorite anime by query.

The stream option is disabled automatically if the project cannot find any of the supported streamers.

stream / download / grab

These commands are the main set of command in the project. All of them scrape the target site, the only difference is how it is used.

animdl stream "One Piece" 

Providers can be specified by using provider prefix, 9anime:One Piece, will use the 9Anime provider.

You can specify direct urls to the provider; the project will automatically detect the provider and continue scraping. This method ignores searching.

-r / --range argument

This argument is shared by stream, download and grab, it can be used to hand over custom ranges for selecting episodes.

--index argument

This argument is shared by stream, download and grab, it can be used to automatically select the search result. The default argument for index is 1, that is, the first stream.

--index 2 will automatically select the second search result without prompt.

-s / --special argument

This argument is shared by stream and download, it can be used to hand over the latest episode of the anime by using -s latest. Similarly, the latest 2 episodes can be selected via latest-2.

-q / --quality argument

This argument is incredibly powerful and can be used to select streams from their attributes.

You can find out what attributes are available for each stream by using the grab command.

[
  {
    "stream_url": "https://yqwym.vizcloud.digital/simple/EqPFI_kQBAro1HhYl67rC8UuoVwHubb7CkJ7rqk+wYMnU94US2El/br/list.m3u8#.mp4",
    "headers": {
      "referer": "https://vizcloud.digital/embed/83P7OX0N8PLE"
    }
  },
  {
    "stream_url": "https://yqwym.vidstream.pro/EqPVIPsMWl322yVezviuGdNz9wsVp_2ySFow5Od52MBlQ9QQG34s9aQ0yhbkTfyI+tzdG4991O3X4fVqACOikmeZRvMNGrBeQ5aivXxFIkYzNJElHAM1icyfowvCviiceQevRCxV9F7i7CIYt0hIz61716gsQxXskJ6eV4Gg4_OC/br/list.m3u8",
    "headers": {
      "referer": "https://vizcloud.digital/embed/83P7OX0N8PLE"
    }
  },
  {
    "stream_url": "https://yzqq.mcloud.to/12a3c523f910040ae8d4785897aeeb0bc52ea15c07b9b6fb0a427baea96ed0842f54d0184c6820e9f935c248a146eb8df28cc21a817ad2e8c0eefd680420a692659945f21618bd454698bcbf6e42394f3d4ee734180c3281ce9bb00fcaa2298e7913aa40036bbb0abaf07046a14442c2f32c9df66b1a/r/list.m3u8",
    "headers": {
      "referer": "https://mcloud.to/embed/k18xp6"
    }
  }
]

This is the prettified output of animdl grab "9anime:one piece", and the stream has headers and stream_url attributes.

If you feel that a particular stream is fast enough for you, -q [stream_url=r'.+mcloud\.to.+'](or equivalent, this is just for testing) will select that stream.

Conclusion

This project posses powerful commands and arguments to aid them, there are many arguments that aren't specified here but are available in the project. This is done because these commands are advanced usage commands which may just cause confusion. Feel free to ask about them.

Providers

Please head to animdl's official provider benchmarks.

The images in that repository are automatically updated every few hours, hence, please be aware that the developers already know what's broken.

Some providers may not work due to DDoS protection services. We try our best to fix what's fixable. There are plenty of alternatives even if one goes down in the project.

The project contains providers that aren't mentioned here. This is intentional.

Configurations

Configuration files can be globally or locally be specified.

You can use the ANIMDL_CONFIG environment variable to specify a configuration file on a global level.

Else, a file with the name animdl_config.yml in the working directory will be used if available.

Futhermore, the configuration files can be globally placed at:

Only a singular configuration file in the above priority order is used, configurations aren't merged.

Setting up providers

You can specify a default provider using the default_provider configuration option.

default_provider: animixplay

This project uses a standardised url per provider. This makes the project capable of using different official proxies of the same provider.

This can be specified via site_urls by using the following configuration.

site_urls:
    animixplay: https://www.animixplay.to/

Quality selection

You can specify a default quality using the quality_string configuration option.

quality_string: best[subtitle]/best

Player selection

You can specify a default player using the default_player configuration option.

default_player: mpv

You can change player attributes, such as, what the executable is and what opts are to be passed during the player call.

players:
    mpv:
        executable: mpv
        opts: []

If the executable is found, the player will be eligible for use.

Currently supported players are:

ffmpeg set-up

You can make the project force ffmpeg for HLS downloading (awfully slow) and merging subtitles for downloads when external subtitles are available.

ffmpeg:
    executable: ffmpeg
    hls_download: false
    submerge: true

Discord Rich Presence set-up

This project supports RPC clients, this can be enabled only from the configuration. To use this, you must have pypresence installed via:

pip install pypresence
discord_presence: true

fzf set-up

You can force the project search prompts to use fzf.

This is an incredibly powerful tool and can enchance the user experience by a lot. For obvious reasons, you need to have it installed and on PATH (can be configured to use an executable path as well).

fzf:
    executable: fzf
    opts: []
    state: true

Users can benefit by using fzf and animdl stream twist: as this allows them to browse the entire Twist library with a heavenly interface.

The above screenshot has fzf's user theme configured.

Schedule set-up

The project can be used to view the schedule of the upcoming anime for the week with the user cherished time and date formats.

schedule:
    site_url: https://graphql.anilist.co/ # DO NOT CHANGE UNLESS YOU KNOW WHAT YOU'RE DOING
    date_format: "%b. %d, %A"
    time_format: "%X"

Please refer to Python datetime.strftime documentation for the available formats.

Contributing to the project

It is not recommended for any average Python developers to engage with the project codebase as the mechanisms used are extremely high level and requires greater understanding of the codebase and Python in general.

If you wish to, you can contribute to the project by submitting a pull request.

The best way to contribute would be to suggest the developer a provider or a feature, more better if you can show a logic of how that can be done, you'll be mentioned and thanked!

Project disclaimer

The disclaimer of the project can be found here.

In a nutshell

Code redistribution

Feel free to do so and take references from the codebase. You need not give credit to the project or justfoolingaround, however, please do a blame check and see if the contributor wants to be credited.

From the author

I just maintain this project for my gratification. I'd love to hear from you about your projects and problems (even unrelated to the project), so feel free to contact me.

I'm glad you're here!

Honourable mentions

Similar Projects

These are actively maintained projects, each of which has its own unique features and functionality.

Internal Dependencies

The project would definitely not be complete or even in a working state if it weren't for these dependencies.

Sponsoring the project

Usually sponsors means funding which consequently means money but for the project, it means stars. Feel free to star the project if you think it is worthy of one. Moreover, you can just talk, banter and argue with the developer as that way you'll be paying with your time.

You are an absolute legend, keep being awesome!