download
Downloader(progress_callback=None, info_callback=None, soft_error_callback=None)
¶
Downloader class to download streams retrieved by the Providers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
progress_callback
|
Optional[ProgressCallback]
|
A callback with an percentage argument, that gets called on download progress. |
None
|
info_callback
|
Optional[InfoCallback]
|
A callback with an message argument, that gets called on certain events. |
None
|
soft_error_callback
|
Optional[InfoCallback]
|
A callback with a message argument, when certain events cause a non-fatal error (if none given, alternative fallback is info_callback). |
None
|
Source code in api/src/anipy_api/download.py
download(stream, download_path, container=None, ffmpeg=False, max_retry=3, post_dl_cb=None)
¶
Generic download function that determines the best way to download a
specific stream and downloads it. The suffix should be omitted here,
you can instead use the container
argument to remux the stream after
the download, note that this will trigger the progress_callback
again. This function assumes that ffmpeg is installed on the system,
because if the stream is neither m3u8 or mp4 it will default to
ffmpeg_download.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stream
|
ProviderStream
|
The stream to download |
required |
download_path
|
Path
|
The path to download the stream to. |
required |
container
|
Optional[str]
|
The container to remux the video to if it is not already correctly muxed, the user must have ffmpeg installed on the system. Containers may include all containers supported by FFmpeg e.g. ".mp4", ".mkv" etc... |
None
|
ffmpeg
|
bool
|
Wheter to automatically default to ffmpeg_download for m3u8/hls streams. |
False
|
max_retry
|
int
|
The amount of times the API can retry the download |
3
|
post_dl_cb
|
Optional[PostDownloadCallback]
|
Called when completing download, not called when file already exsists |
None
|
Returns:
Type | Description |
---|---|
Path
|
The path of the resulting file |
Source code in api/src/anipy_api/download.py
ffmpeg_download(stream, download_path)
¶
Download a stream with FFmpeg, FFmpeg needs to be installed on the
system. FFmpeg will be able to handle about any stream and it is also
able to remux the resulting video. By changing the suffix of the
download_path
you are able to tell ffmpeg to remux to a specific
container.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stream
|
ProviderStream
|
The stream |
required |
download_path
|
Path
|
The path to download to including a specific suffix. |
required |
Returns:
Type | Description |
---|---|
Path
|
The download path, this should be the same as the |
Path
|
passed one as ffmpeg will remux to about any container. |
Source code in api/src/anipy_api/download.py
m3u8_download(stream, download_path)
¶
Download a m3u8/hls stream to a specified download path in a ts container.
The suffix of the download path will be replaced (or added) with ".ts", use the path returned instead of the passed path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stream
|
ProviderStream
|
The m3u8/hls stream |
required |
download_path
|
Path
|
The path to save the downloaded stream to |
required |
Raises:
Type | Description |
---|---|
DownloadError
|
Raised on download error |
Returns:
Type | Description |
---|---|
Path
|
The path with a ".ts" suffix |
Source code in api/src/anipy_api/download.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
mp4_download(stream, download_path)
¶
Download a mp4 stream to a specified download path.
The suffix of the download path will be replaced (or added) with ".mp4", use the path returned instead of the passed path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stream
|
ProviderStream
|
The mp4 stream |
required |
download_path
|
Path
|
The path to download the stream to |
required |
Returns:
Type | Description |
---|---|
Path
|
The download path with a ".mp4" suffix |
Source code in api/src/anipy_api/download.py
InfoCallback
¶
Bases: Protocol
Callback that accepts a message argument.
PostDownloadCallback
¶
Bases: Protocol
Callback that accepts a message argument.
__call__(path, stream)
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path
|
Path of the resulting download, passed to the callback |
required |
stream
|
ProviderStream
|
ProviderStream object passed to the callback |
required |