Skip to content
/ VT-PR Public

VineTrimmer with PlayReady support, WIP. A DRM Removal Framework for Streaming Services.

License

Notifications You must be signed in to change notification settings

chu23465/VT-PR

Repository files navigation

VineTrimmer-PlayReady

A tool to download and remove DRM from streaming services. Modified to remove Playready DRM in addition to Widevine DRM.

The name VineTrimmer comes from Vine as in WideVine and Trimmer as in remove.

Disclaimer!!!

This project is ONLY for educational/archival/personal purposes. I do not condone piracy in any form.

I AM NOT taking credit for the entirety of this project. This project is based on a version of an old fork of devine that was found floating around online. I AM taking credit for about 20% of the additional stuff that I personally worked on.

Supporters

@m41c0n

Features

  • Progress Bars for decryption (mp4decrypt, Shaka)
  • Refresh Token fixed for Amazon service
  • Reprovision .prd after 2 days
  • ISM manifest support (Microsoft Smooth Streaming) (WIP/Experimental)
  • N_m3u8DL-RE downloader support

Usage

  1. Install Microsoft Visual C++ Redistributable - link.

  2. Ensure Python is installed in your system (cannot be from the the Microsoft Store). Refer to link or on Ubuntu -> sudo apt install python3. I recommend python 3.10.11 (or higher).

  3. Make sure git is installed in your system by running git --version. If not refer to link

  4. Choose a branch, either dev or main. Use below command to download. (Recommended instead of downloading zip)

    git clone -b <branch-name> --single-branch https://github.com/chu23465/VT-PR
  5. Navigate and find install.bat

  6. Run install.bat

  7. Activate venv using venv.cmd.

  8. Run desired command using poetry.

Updating

  1. Backup your vinetrimmer/Cookies/, vinetrimmer/Cache/, /Downloads directories just in case.

  2. Open a command prompt and navigate your VT-PR directory.

  3. Recall the branch you downloaded and modify below command accordingly:

    git pull origin <branch-name>

Config

vinetrimmer.yml located within the /vinetrimmer/ folder.

decryptor: either mp4decrypt or packager

(shaka-packager fails to decrypt files downloaded from ISM/Microsoft Smooth Streaming manifests)

tag: tag for your release group

CDM can be configured per service or per profile.

cdm:
    default: {text}
    Amazon: {text}

All other option can be left to defaults, unless you know what you are doing.

General Options

Usage: vt.cmd [OPTIONS] COMMAND [ARGS]...

Options:

Command line argument Description Default Value
-d, --debug Flag to enable debug logging False
-p, --profile Profile to use when multiple profiles are defined for a service. "default"
-q, --quality Download Resolution ie Height of Video Track wanted 1080
-cr, --closest-resolution If resolution specified is not found, defaults to closest resolution available False
-v, --vcodec Video Codec H264
-a, --acodec Audio Codec None
-vb, --vbitrate Video Bitrate, Min or a number based on output of --list Max
-ab, --abitrate Audio Bitrate Max
-aa, --atmos Prefer Atmos Audio False
-r, --range Video Color Range HDR, HDR10, DV, SDR SDR
-w, --wanted Wanted episodes, e.g. S01-S05,S07, S01E01-S02E03, S02-S02E03 Default to all
-le, --latest-episode Download only the latest episode on episodes list False
-al, --alang Language wanted for audio. Defaults to original language
-sl, --slang Language wanted for subtitles. Defaults to original language
--proxy Proxy URI to use. If a 2-letter country is provided, it will try get a proxy from the config. None
-A, --audio-only Only download audio tracks. False
-S, --subs-only Only download subtitle tracks. False
-C, --chapters-only Only download chapters. False
-ns, --no-subs Do not download subtitle tracks. False
-na, --no-audio Do not download audio tracks. False
-nv, --no-video Do not download video tracks. False
-nc, --no-chapters Do not download chapters tracks. False
-ad, --audio-description Download audio description tracks. False
--list Skip downloading and list available tracks and what tracks would have been downloaded. False
--selected List selected tracks and what tracks are downloaded. False
--cdm Override the CDM that will be used for decryption. None
--keys Skip downloading, retrieve the decryption keys (via CDM or Key Vaults) and print them. False
--cache Disable the use of the CDM and only retrieve decryption keys from Key Vaults. If a needed key is unable to be retrieved from any Key Vaults, the title is skipped. False
--no-cache Disable the use of Key Vaults and only retrieve decryption keys from the CDM. False
--no-proxy Force disable all proxy use. False
-nm, --no-mux Do not mux the downloaded and decrypted tracks. False
--mux Force muxing when using --audio-only/--subs-only/--chapters-only. False
-?, -h, --help Show this message and exit.

COMMAND :-

Alaias Command Service Link
AMZN Amazon https://amazon.com, https://primevideo.com
ATVP AppleTVPlus https://tv.apple.com
MAX Max https://max.com
NF Netflix https://netflix.com
PCOK Peacock https://peacocktv.com/
HS Hotstar https://www.hotstar.com/

Amazon Specific Options

Usage: vt.cmd AMZN [OPTIONS] [TITLE]

Service code for Amazon VOD (https://amazon.com) and Amazon Prime Video (https://primevideo.com).

Authorization: Cookies

Security:

UHD@L1/SL3000
FHD@L3(ChromeCDM)/SL2000
SD@L3

Certain SL2000 can do UHD

Maintains their own license server like Netflix, be cautious.

Region is chosen automatically based on domain extension found in cookies. Prime Video specific code will be run if the ASIN is detected to be a prime video variant. Use 'Amazon Video ASIN Display' for Tampermonkey addon for ASIN https://greasyfork.org/en/scripts/496577-amazon-video-asin-display

vt dl --list -z uk -q 1080 Amazon B09SLGYLK8

Below flags to be passed after the AMZN or Amazon keyword in command.

Command Line Switch Description
-b, --bitrate Video Bitrate Mode to download in. CVBR=Constrained Variable Bitrate, CBR=Constant Bitrate. (CVBR or CBR or CVBR+CBR)
-c, --cdn CDN to download from, defaults to the CDN with the highest weight set by Amazon.
-vq, --vquality Manifest quality to request. (SD or HD or UHD)
-s, --single Force single episode/season instead of getting series ASIN.
-am, --amanifest Manifest to use for audio. Defaults to H265 if the video manifest is missing 640k audio. (CVBR or CBR or H265)
-aq, --aquality Manifest quality to request for audio. Defaults to the same as --quality. (SD or HD or UHD)
-ism, --ism Set manifest override to SmoothStreaming. Defaults to DASH w/o this flag.
-?, -h, --help Show this message and exit.

To get Atmos/UHD/4k with Amazon, navigate to -

https://www.primevideo.com/region/eu/ontv/code?ref_=atv_auth_red_aft

Login and get to the code pair page. Extract cookies from that page using Open Cookies.txt.

Save it to the path vinetrimmer/Cookies/Amazon/default.txt. Pay attention to path if you are on Linux. Path is case sensitive and needs the capital C for Cookies and capital A for Amazon.

When caching cookies, use a profile without PIN. Otherwise it may cause errors.

Peacock

  • PCOK bans leaked certs quickly (for 4k), be cautious.
  • Authorization - cookies saved to vinetrimmer/Cookies/Peacock/default.txt

Hotstar

  • To use, login to Hotstar and navigate to https://www.hotstar.com/{region}/home. Extract cookies from that page and save to path vinetrimmer\Cookies\Hotstar\default.txt (Case sensitive).
  • Otherwise add credentials to vinetrimmer.yml. An example is given.
  • A free account has access to lots of content.
  • Hotstar requires an Indian (+91) phone number to signup to Indian region, even for free account.
  • Hates VPN's, get a residential proxy of some sort.
  • All content is licensed via Widevine L3 or has no DRM.

Example Command

Amazon Example:

poetry run vt dl -al en -sl all --selected -q 2160 -r HDR -w S01E18-S01E25 AMZN -b CBR --ism 0IQZZIJ6W6TT2CXPT6ZOZYX396

Above command:

  • gets english audio,
  • gets all available subtitles,
  • selects the HDR + 4K track,
  • gets episodes from S01E18 to S01E25 from Amazon
  • with CBR bitrate,
  • tries to force ISM
  • and the title-ID is 0IQZZIJ6W6TT2CXPT6ZOZYX396

AppleTV Example:

poetry run vt dl -al en,it -sl en,es -q 720 --proxy http://192.168.0.99:9766 -w S01E01 ATVP umc.cmc.1nfdfd5zlk05fo1bwwetzldy3

Above command:

  • gets english, italian audio
  • gets english, spanish subtitles,
  • lists all possible qualities,
  • selects 720p video track,
  • uses the proxy for licensing,
  • gets the first episode of first season (i.e S01E01)
  • of the title-ID umc.cmc.1nfdfd5zlk05fo1bwwetzldy3

Max Example:

poetry run vt dl -al en -sl en --keys --proxy http://192.168.0.99:9766 MAX https://play.max.com/show/5756c2bf-36f8-4890-b1f9-ef168f1d8e9c

Above command:

  • gets english subtitles + audio,
  • skips download and only gets the content keys,
  • from MAX
  • uses specified proxy
  • defaulting to HD for video
  • title-ID is 5756c2bf-36f8-4890-b1f9-ef168f1d8e9c

Hotstar Example:

poetry run vt dl -al en -sl en -q 2160 -v H265 HS https://www.hotstar.com/in/movies/hridayam/1260083403

Above command:

  • gets english subtitles + audio,
  • sets video codec to H265 codec,
  • sets video quality (ie. resolution) to 2160p,
  • Gets highest quality video/audio available.
  • title-ID is 1271342309

Proxy

I recommend Windscribe. You can sign up, getting 10 GB of traffic credit every month for free. We use the VPN for everything except downloading video/audio. Tested so far on Amazon, AppleTVPlus, Max.

Steps:

  1. For each service, within get_tracks() function we do this below. Below is only when you are integrating a new service yourself. Set needs_proxy to True if your service needs proxy to get manifest (Ex - Netflix, Hotstar).

    for track in tracks:
        track.needs_proxy = False

    This flag signals that this track does not need a proxy and a proxy will not be passed to downloader even if proxy given in CLI options.

  2. Download Windscribe app and install it.

  3. Go to Options -> Connection -> Split Tunneling. Enable it.

    Set Mode as Inclusive.

  4. Go to Options -> Connection -> Proxy Gateway. Enable it. Select Proxy Type as HTTP.

    Copy the IP field (will look something like 192.168.0.141:9766)

    Pass above copied to Vinetrimmer with the proxy flag like below.

    ...(other flags)... --proxy http://192.168.0.141:9766 .......

    If you are using other VPNs, extract the proxy (use the browser extension to do this). It will look something like http(s)://username:pass@host/IP:PORT. Ex -> https://user:pass@domain.com:443. Pass it like below:

     ...(other flags)... --proxy https://user:pass@domain.com:443 .......

Other

  • For --keys to work with ATVP you need to pass the --no-subs flag.

  • Errors arise when running VT within Docker or Conda like python environments. Make sure to use proper python3.

  • To use programs in scripts folder, first activate venv then, then -

    poetry run python scripts/ParseKeybox.py
  • There is another way of running this instead of using poetry. In root folder of VT-PR there is a vt.py (which is essentially the same as vinetrimmer/vinetrimmer.py). Activate venv, then:

    python vt.py dl ......(rest of the command as before).......

    This is useful for debugging/stepping through in IDE's without having to deal with poetry.

  • Nuitka compile:

    • Activate venv, then

    • python -m pip install nuitka

    • Verify using command nuitka --version

    • Then:

      nuitka --standalone --output-dir=dist --windows-console-mode=force vt.py --include-data-dir=./vinetrimmer/=vinetrimmer/ --include-data-dir=./binaries/=binaries
    • --standalone will give a folder of compiled pythonic objects. Zip it to distribute. This is recommended.

    • If you don't want to carry around/deal with a zip, instead use --onefile. This has the drawback of setting the default folders to the temp folder in whatever OS you are using. This could be fixed with some extra code but that is currently not implemented.

Broken / To-Do (Descending order of priority)

  • First stable release
  • Shaka with progress bar repo
  • Fix cdm type errors.
  • Insert command to start of log in vt
  • Linux support - Debian/Ubuntu/Mint
  • Single script that installs, and if already installed checks for and applies updates
  • Replace poetry with uv
  • Add m4ffdecrypt
  • Add a version.py
  • Downloader field in config, per service.
  • Fix service config load for Linux.
  • Make a script to download latest binaries for vt automatically at startup.
  • Detect if running as Nuikta compiled binary, then in vt.py set directories relative to binary path
  • Find a way to estimate final file size for a track. Check if enough space is left on disc for double the amount of selected tracks - since mp4decrypt and Nm3u8 both make copies of the files
  • Merge DB script
  • Latest mkvtoolnix for linux
  • Modify aria2c to include a progress bar ?
  • Github Actions Python script that builds and publishes release for every commit to not readme.md
  • MAX - Fix HDR10/DV --list
  • ATVP service is currently broken in dev branch
  • Fix original language (Was removed as workaround for a bug)
  • Fix -sl all and -al all
  • Make a windscribe.py for proxies modelled after nordvpn.py. Refer to the chrome extension for the code.
  • Move to requests, curl or otherwise to download subtitles (?)
  • Netflix service is currently broken (will probably be fixed Soon™)
  • Integrate subby
  • Licensing before download (?)
  • Add MoviesAnywhere, ParmountPlus, DisneyPlus services.
  • Guide for writing a service + debugging
  • Implement a scan/hammer/cache keys for each service - pass string of zeros as title id. Then copy and rework dl.py to iterate over returned list of titles from scan function
  • Pyinstaller support ?

Amazon Specific

  • Pythonic implementation of init.mp4 builder for ism manifest for avc, hvcc, dv, ac3, eac3, eac3-joc codecs
  • Make a pure python requests based downloader for ISM/MSS manifest. Write init.mp4 then download each segment to memory, decrypt in memory and write it to a binary merged file. Download segments in batches. Batch size based on thread count passed to program. Download has to be sequentially written.
  • --bitrate CVBR+CBR is currently broken
  • Get highest quality CBR and CVBR MPD+ISM by default to AMZN
  • Specify devices in config for MPD or ISM then load one based on command
  • For videos, download init.mp4 using N_m3u8, mediainfo it to get FPS, HDR info
  • Manifest url caching system for every key/Track object.
  • Atmos audio with ISM manifest (Amazon) is currently broken (Needs a working initialization segment - init.mp4. If the title has the atmos audio in MPD then it should work.) ISM EAC3 - ddp / atmos needs dec3 box.

If anyone has any idea how to fix above issues, feel free to open a pull request.

Donating

I am an independent developer right now. I work on this project in my free time. If you could support me that would be immensely helpful. All supporters will get a special mention in the README. Thank you in advance.

My Buymeacoffee.

My discord is @crapola

Additional Credits

@rlaphoenix for pywidevine

@DevLARLEY for pyplayready

@FieryFly for an additional MAX fix.

@Wiesiek on Discord for a few ideas

DRM-Lab-Project for numerous bug fixes and support.

Playready-Discord for numerous bug fixes and support.

CDRM-Project and @TPD94, @radizu for getting me started on this journey, being a source of inspiration and for keeping a community well and alive.

Star History

Star History Chart

About

VineTrimmer with PlayReady support, WIP. A DRM Removal Framework for Streaming Services.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages