Commit Graph

335 Commits

Author SHA1 Message Date
rlaphoenix 6cfbaa7db1 Pass cookies to the aria2c and requests downloaders
For aria2c I've simplified the operation by offloading most of the work for creating a cookie header by just re-doing what Python-requests does. This results in the exact same cookies Python-requests would have used in a requests.get() call or such. It supports multiple of the same-name cookies under different domains/paths based on the URI of the mock request.
2023-05-29 22:23:39 +01:00
rlaphoenix 1ff4858ca7 Fix mistake in Web Address for FFmpeg in README 2023-05-28 19:46:55 +01:00
rlaphoenix fd52073605 Skip merging of HLS segments if `--skip-dl` is used
Partially fixes #61
2023-05-27 20:20:07 +01:00
rlaphoenix 89f5e04348 Bump requests from 2.28.2 to 2.31.0 2023-05-27 20:15:51 +01:00
rlaphoenix 57af8d98c9 Add --video-only flag to dl command 2023-05-26 11:16:12 +01:00
rlaphoenix 215730663b Allow --audio/subs/chapters-only to be used simultaneously
E.g., if you only wanted the subs and chapters, this would now be possible with `--subs-only --chapters-only`.
2023-05-26 11:15:38 +01:00
rlaphoenix 6a9598021d Re-raise errors when loading WVD files so it's more understandable
It also looks for the "expected 2 but parsed 1" error which is likely an error while parsing the WVD version field. If this happens, it will inform the user to use `pywidevine migrate`.
2023-05-25 04:45:49 +01:00
rlaphoenix a24633fe61 List available Services on error
This is mainly to lessen confusion on service name typo's or new users getting used to the CLI.

It also changed the Exceptions on the methods of Service from ClickException to a KeyError since they are intended to be used on the core codebase outside of the context of Click.
2023-05-25 04:37:17 +01:00
rlaphoenix df2f9b85ae Use urljoin instead of an if check and + op in HLS
This used to be used even before devine was public, but it was constantly changed back and forth between an urljoin(), another form of urljoin (something custom or something I can't remember), and an if check + addition.

However, I can confirm that a simple if check will not work as the Base URI might not even be in the same relative root. The if checks have also been inconsistent with some checking if it starts with http(s)://, and some checking if it does not have the base URI at the start of the string.

This if check method does not work as well as an urljoin() has the potential to. It also fixes some services as some HLS playlists would have the m3u8 URL on a completely different root, subdomain, or even domain, causing it to completely break when trying to download segments.
2023-05-21 00:06:30 +01:00
rlaphoenix 301c026ca9 Remove Smart/Fancy Left/Right Quotation Marks from Filename Sanitizer 2023-05-20 22:10:55 +01:00
rlaphoenix 8df04de1ea Remove file size check from Requests downloader
We cannot actually do this check. The Content-Length value will be the size after being further encoded or compressed. While we can find out what it was compressed with via the Content-Encoding header, we cannot match the downloaded length with the Content-Length header as requests will automatically decompress/decode according to the Content-Encoding header.
2023-05-19 22:11:05 +01:00
rlaphoenix 8ada6165e3 Set stop event & mark track failed if DASH DRM fails to license 2023-05-19 19:07:35 +01:00
rlaphoenix 6e844409ae Set stop event & mark track failed if HLS Session DRM fails to license 2023-05-19 19:07:06 +01:00
rlaphoenix c9ecab444f Use range offset when calculating HLS init map byte ranges 2023-05-19 18:38:33 +01:00
rlaphoenix 3e0b7ef200 Fix regression where Range header is accidentally kept and re-used 2023-05-19 00:35:46 +01:00
rlaphoenix 8e7a63f0b9 Fix the file move in `wvd add` when the WVDs folder does not exist
On new installs, or where the `WVDs` folder is not made yet, then the shutil.move() assumes it's a file path and moves the `.wvd` file to the WVDs folder path, as a file. If the folder existed but was empty, this error wouldn't have occurred.
2023-05-19 00:35:46 +01:00
rlaphoenix 55a86ac6c9 Fix filesize.decimal call in requests downloader size exception 2023-05-17 03:32:08 +01:00
rlaphoenix dd64212ad2 Move download_segment() from DASH/HLS download_track() to Class
Various overall small readability improvements have also been made.
2023-05-17 03:20:01 +01:00
rlaphoenix 03c012f88e Move the Downloaded msg after Decrypt mgs in DASH/URL downloads 2023-05-17 02:09:16 +01:00
rlaphoenix 6cdde3efb0 Override the downloader more efficiently in DASH/HLS when Range is used 2023-05-17 01:33:06 +01:00
rlaphoenix 6d4be8620c Only write segment data if the tfhd fix was necessary in DASH 2023-05-17 01:22:59 +01:00
rlaphoenix 681d69d5e5 Mark DASH and URL tracks as Decrypting when using shaka
DASH and normal URL downloads now both decrypt one large single or merged file after all downloads are finished. This leaves a bit of a "pause" between progress bar movement which looks a bit odd. So mark the track as being in a Decrypting state.
2023-05-16 22:01:07 +01:00
rlaphoenix a45c784569 Replace download speeds with "Downloaded" text when finished 2023-05-16 21:59:03 +01:00
rlaphoenix 2a8307b98d Decrypt DASH downloads after merging all segments
Since DASH doesn't have the ability to change keys dynamically per-track (Representation), there's no need for the DASH downloader to decrypt segments as they are downloaded (like HLS).

This halves the amount of processes needing to be opened as well as the I/O usage. It may result in noticeably lower CPU usage. Since the IOPS is lowered, you may even see an increase in download speed if downloading to something like a meh HDD.

This also fixes decryption in some weird edge-cases where decrypting each segment individually resulted in timestamp anomalies causing shaka to fail.
2023-05-16 21:55:53 +01:00
rlaphoenix bdc1203514 Only verify download size in requests downloader if possible
Some Servers may not response with the Content-Length header, even if it's from segmented media. I.e., if it's a subtitle URL. The requests downloader required the header to be present as it downloads each URL, which is not possible.

Now it tries to get it if possible, and verifies the download size with the Content-Length value if it could be obtained.
2023-05-16 20:49:43 +01:00
rlaphoenix 2a4e9505f1 Remove unnecessary HEAD calls in requests downloader
HEAD requests were made to sum a total file size of the download operation. However, the downloader is may be used on URLs where the content is not segmented media. Therefore, the server may not support or respond with the Content-Length header which causes the requests downloader to crash before it even gets a chance to begin downloading.

Even still, this total size value isn't really necessary, and would cause possibly 100s of HEAD requests (in quick succession of each other) on segmented sources. It would also add up-front delay before it actually starts to download.
2023-05-16 20:47:26 +01:00
rlaphoenix e7dc138c0f Improve readability and documentation of DASH's to_tracks function 2023-05-15 16:19:53 +01:00
rlaphoenix e079febe79 Ensure output directory exists in requests downloader 2023-05-15 13:33:59 +01:00
rlaphoenix 95802d1e64 Fix regression with downloader mapper on aria2c and saldl
The setup I had for using asyncio.run with functools.partial didn't actually pan out. A full pass-through lambda is required.

I've also moved the mapped downloader variable to the root of the downloaders package.
2023-05-12 12:19:34 +01:00
rlaphoenix be403bbff4 Implement a Python-requests-based downloader 2023-05-12 07:02:39 +01:00
rlaphoenix cb82febb7c Add ability to choose downloader via config 2023-05-12 06:42:33 +01:00
rlaphoenix b92708ef45 Alter behaviour of --skip-dl to allow DRM licensing
Most people used --skip-dl just to license the DRM pre-v1.3.0. Which makes sense, --skip-dl is otherwise a pointless feature. I've fixed it so that --skip-dl worked like before, allowing license calls, while still supporting the new per-segment features post-v1.3.0.

Fixes #37
2023-05-11 22:17:41 +01:00
rlaphoenix 3ec317e9d6 Pass manifest to DASH downloader instead of re-requesting it
Fixes #51
2023-05-11 20:46:37 +01:00
rlaphoenix 5ca2f256d5 Fix URL used on final chance to get Track KID on DASH downloads
segments[0] is the first tuple, of two values. The URL and an optional byte range. So this accidentally passed the tuple rather than the URL within the tuple.

Fixes #54
2023-05-09 13:04:20 +01:00
rlaphoenix 1668647e4d Change ConstError for ValidationError when ignoring tenc errors
The change to pymp4 may result in it complaining when validating parameters of the tenc box data, i.e., if the version byte is not 0 or 1, e.t.c. It shouldn't do a ConstError on tenc boxes anymore as the definition of the tenc box has been much improved in pymp4 v1.4.0.
2023-05-08 17:41:55 +01:00
rlaphoenix bf82065400 Move back to the official pymp4 dependency
All the latest changes in my fork is now available on the official pymp4 repository, and a new PyPI release v1.4.0 is available with the fixes to use.
2023-05-07 18:30:42 +01:00
rlaphoenix 3ae0fb3454 Update Actions in GitHub Actions CI/CD workflows 2023-05-03 03:05:11 +01:00
rlaphoenix 1c5099440b Add FLAC to the Audio Codecs enum and relevant methods 2023-05-01 18:49:25 +01:00
rlaphoenix e3941e4640 Remove now unnecessary explicit version checks on tenc boxes
pymp4 was updated to automatically do this during parsing and building of tenc boxes. Therefore it would instead fail parsing if the version is not 0 or 1.
2023-04-23 22:39:14 +01:00
rlaphoenix 2b07399f5a Update dependency on my fork of pymp4
It may look like I'm downgrading, but I'm not.

1.5.0 was an incorrect version bump based on TrueDread's fork. v1.4.0 is the next release after, even though it's a lower version. v1.4.0 should be used instead.
2023-04-23 22:36:41 +01:00
rlaphoenix b5263491ab Update Changelog for v2.2.0 2023-04-23 18:38:57 +01:00
rlaphoenix bd40c38d23 Bump to v2.2.0 2023-04-23 18:38:47 +01:00
rlaphoenix 630832e434 Ignore failed parsing of tenc boxes
Some services accidentally (? I presume) mix up the `tenc` box's data with that of an `avc1` box or similar. This causes total failure and crashing. However, in these scenarios there's usually a 2nd box further down the stream that is not an error and will parse correctly. So just skip these errors and continue.
2023-04-23 17:38:12 +01:00
rlaphoenix 86322159b6 Fix multiplexing of downloads without a video track
E.g., --subs-only and --audio-only
2023-04-17 14:09:36 +01:00
rlaphoenix 96aa7c1e0a Fix segmented vtt merging code
This got 'broken' after moving to my fork of pymp4 because my fork has commits by TrueDread that add support for the vttc, payl, and sttg boxes, therefore they no longer contain `data` fields but rather specifically parsed fields. I also no longer need to parse the data stream of vttc boxes, as they are already parsed as `children`.
2023-04-04 20:15:18 +01:00
rlaphoenix 62965f8e21 Skip tenc boxes that are not version 0 or 1
It seems tenc boxes should only be 0 or 1, yet sometimes it can be above that. It seems some services accidentally use the `tenc` atom code over another. E.g., Netflix sometimes using `tenc` instead of `avc1`.
2023-03-28 21:27:43 +01:00
rlaphoenix eb39c8eba6 Ensure QualityList returns resolutions in descending order 2023-03-28 20:46:13 +01:00
rlaphoenix b301fb4390 Use tenc boxes within uuid boxes as another fallback for get_key_id 2023-03-28 20:25:30 +01:00
rlaphoenix 5b7fadbc55 Use -nobom with CCExtractor 2023-03-27 19:25:21 +01:00
rlaphoenix 527cd4cca1 Fix regression where only last mux would be moved to dl folder 2023-03-27 18:51:32 +01:00