Commit Graph

561 Commits

Author SHA1 Message Date
rlaphoenix 7ca58c96ab Shorten variable `aria_log_buffer` to `log_buffer` 2023-03-12 00:12:48 +00:00
rlaphoenix 90818f201d Include the mkvmerge return code on error 2023-03-12 00:10:54 +00:00
rlaphoenix d8acdda044 Silence DASH and HLS logs unless it's the last attempt 2023-03-12 00:09:02 +00:00
rlaphoenix 055bc927f5 Add a 5-attempt retry system to DASH & HLS downloads 2023-03-11 19:28:02 +00:00
rlaphoenix 111dac9264 Fix association of preceding HLS EXT-X-KEYs with m3u8 fork
This will improve efficiency and accuracy of getting appropriate DRM systems when downloading segments.

This can dramatically improve download speed from less than 50 kb/s to full speed if the HLS playlist used a lot of AES-128 EXT-X-KEYs. E.g., a unique key for each segment.

This was caused because the HLS.get_drm function took EVERY EXT-X-KEY, checked for supported systems, loaded them, and returned the supported objects. This meant it could load possibly 100s of AES-128 ClearKey objects (likely requiring URL downloads for the key URI) causing a huge delay before downloading each segment.
2023-03-09 21:46:48 +00:00
rlaphoenix 7bb215d496 Prevent licensing Widevine DRM a second time
If you use --cdm-only, you will end up licensing multiple times if the PSSH has more than one Key ID. While this is checked for, with the KID check now being more lenient, it will end up continuing and licensing again.

However, even with the original check code this would have been pointless. If the first license did not return a content key for a KID, then the next license call with the exact same parameters wouldn't have either
2023-03-08 22:48:36 +00:00
rlaphoenix abf6c71688 Specify HLS Track Key IDs to prepare_drm
This also moves the init data code before drm related code, just so it has the init data ready to retrieve the Key ID from.
2023-03-08 22:45:41 +00:00
rlaphoenix da7acb0417 Specify URL Track Key IDs to prepare_drm 2023-03-08 22:42:25 +00:00
rlaphoenix a549cc6afb Specify DASH Track Key IDs to prepare_drm 2023-03-08 22:41:58 +00:00
rlaphoenix 923cb71f81 Only raise error if the Track's KID was not found when licensing
For ex., if a service has the same PSSH or license call for 720p and 1080p video tracks, but it doesn't return a KID for the 1080p track, then the previous code would return an error, even though it has enough content key data to continue.

With this change it now only raises the error if the track's exact KID was not licensed. This adds support to prepare_drm for specifying the track's KID.
2023-03-08 22:41:13 +00:00
rlaphoenix 73bd17ec94 Implement new get_key_id() method to Track 2023-03-08 22:36:21 +00:00
rlaphoenix 853a021ac0 Fix regression in new get_init_segment, change fallback_size to maximum_size
When the Content-Size is successfully determined, it still uses the (now called maximum_size) as it could otherwise be MBs or GBs worth of data.
2023-03-08 22:27:38 +00:00
rlaphoenix 573dd8cd49 Don't immediately license DASH DRM until used
This is unnecessary as the DASH track may get converted into an URL track, which will also prepare the DRM.
2023-03-08 21:42:05 +00:00
rlaphoenix 8337162991 Prepare DRM on URL tracks if they already have DRM
Previously it would only prepare the DRM, if it had to find DRM from the init data. Now it prepares DRM if already pre-provided with DRM objects.
2023-03-08 21:35:14 +00:00
rlaphoenix d73256f1b3 Fix storing of DRM to be before preparation on URL tracks 2023-03-08 21:31:44 +00:00
rlaphoenix 32c118ab57 Rewrite Track's get_init_segment method, now more dynamic
- DASH and HSL tracks must now explicitly provide the URL to download as the init segment. This is because the original code assumed the first segment, or first init segment was the one that the caller wants, which may not be the case (e.g., and ad is the first init segment).

It now supports explicitly providing a byte-range to download, as well as modifying the fallback content size of 20KB.

It now also checks if the server supports the HTTP Range header and uses it over the hacky request-streaming method. It also checks for the file size and uses that over the fallback size as long as it's not bigger than 100 KB.

Overall it's now more dynamic to specific use-cases, and more efficient in various ways.
2023-03-08 21:08:50 +00:00
rlaphoenix 4f1d94dd7b Remove list unpack from Widevine's from_track for HLS tracks
This isn't actually necessary. Likely hasn't been necessary since either v1.0.0, or v1.2.0.
2023-03-08 20:43:25 +00:00
rlaphoenix cbd796463d Ignore "aria2 will resume download" logs
These only happen if we intentionally cancel the process, or failed. However, this is something that is generally obvious given the args, and when cancelling a wall of these logs would appear.
2023-03-08 13:46:55 +00:00
rlaphoenix fa84ef53e7 Don't space the `*` that denotes KIDs within PSSH
This prevents it from being 1 character over the size limit and wrapping to the next line.
2023-03-08 13:43:11 +00:00
rlaphoenix b3fdafcf06 Simplify Base URL joining and calculation on DASH
This also fixes some DASH manifests where it uses multiple BaseURL definitions that must be joined together.
2023-03-07 12:36:00 +00:00
rlaphoenix cddfdf6336 Update Changelog for v2.0.1 2023-03-07 10:28:18 +00:00
rlaphoenix eaf7752dde Bump to v2.0.1 2023-03-07 10:28:07 +00:00
rlaphoenix d175ffaf15 Add support for byte-range on HLS init maps 2023-03-04 12:21:28 +00:00
rlaphoenix 1b1412d498 Fix byte range calculation on HLS downloads
It was off by one. The final calculation for the right-side range needed to be converted from one-index to zero-index.
2023-03-04 12:18:19 +00:00
rlaphoenix 318832e6b2 Store DRM in the track.drm property in HLS and DASH 2023-03-04 11:49:53 +00:00
rlaphoenix f8166f098c Apply threading lock to HLS DRM preparation
Without this, if two threads started at the same time there was a very good chance they would run the code and license twice, which is unnecessary.
2023-03-04 11:41:10 +00:00
rlaphoenix 0bceb772c2 Handle exceptions in user's Service license funcs 2023-03-04 11:23:58 +00:00
rlaphoenix d9471f886f Raise exceptions in prepare_drm instead of using sys.exit(1) 2023-03-04 11:22:51 +00:00
rlaphoenix 4b330c0478 Implement CEKNotFound and EmptyLicense exceptions to Widevine 2023-03-04 11:18:28 +00:00
rlaphoenix c3a22431f0 Fix possible soft-lock in HLS if Queue is left empty after error 2023-03-04 11:11:20 +00:00
rlaphoenix 7df6aa42b4 Ignore Insufficient bits warning from shaka 2023-03-04 02:31:23 +00:00
rlaphoenix 9fff14af30 Fix regression that broke pproxy 2023-03-03 08:53:28 +00:00
rlaphoenix 19ca567019 Only use captured aria2c output if available 2023-03-03 07:54:31 +00:00
rlaphoenix d964dde4d5 Don't pre-allocate file-space for segmented downloads 2023-03-03 07:52:13 +00:00
rlaphoenix a3efadf00b Fix aria2c's segmented check for DASH/HLS 2023-03-03 07:52:13 +00:00
rlaphoenix 714e9af99a Don't print traceback of subprocess errors on download failures
Since we now have pretty logs for them, the exception (which would be a CalledProcessError) would be generally pointless. However, the return code may be useful so that is kept.
2023-03-03 07:52:13 +00:00
rlaphoenix 9d6adec707 Fix printing of shaka-packager logs 2023-03-03 07:52:13 +00:00
rlaphoenix 9e23ee13bb Remove silent args in aria2c calls for HLS/DASH 2023-03-03 07:52:13 +00:00
rlaphoenix 432a1122c5 Fix printing of aria2c logs when capturing progress 2023-03-03 07:52:13 +00:00
rlaphoenix b2bcaf97a2 Remove double newline after ASCII banner 2023-03-02 16:24:54 +00:00
rlaphoenix cb1a7988f4 Fix centering of project url in ASCII banner 2023-03-02 16:24:01 +00:00
rlaphoenix 3456e24846 State full 'Episode' text if there's no episode name 2023-03-02 16:19:46 +00:00
rlaphoenix f8a8309628 Fix verbose episode listings if there's no episode name 2023-03-02 16:17:20 +00:00
rlaphoenix fc3e49baf6 Update Changelog for v2.0.0 2023-03-01 22:06:08 +00:00
rlaphoenix 46cb1ba0fa Bump to v2.0.0 2023-03-01 22:05:52 +00:00
rlaphoenix 0b1f327a6c Update config documentation on the basic proxy provider 2023-03-01 21:26:52 +00:00
rlaphoenix d75996f6e4 Add title download time elapsed to finish log 2023-03-01 16:06:55 +00:00
rlaphoenix 7ee5e71075 Move download time elapsed code to utilities 2023-03-01 16:06:20 +00:00
rlaphoenix 7b7be47f7d Clean up residual files on download stops and fails 2023-03-01 11:19:32 +00:00
rlaphoenix 9f48aab80c Shutdown HLS & DASH dl pool, pass exceptions to dl
This results in a noticeably faster speed cancelling segmented track downloads on CTRL+C and Errors. It's also reducing code duplication as the dl code will now handle the exception and cleanup for them.

This also simplifies the STOPPING/STOPPED and FAILING/FAILED status messages by quite a bit.
2023-03-01 11:08:52 +00:00