Skip to content

Instantly share code, notes, and snippets.

@bumbummen99
Last active April 29, 2023 16:03
Show Gist options
  • Save bumbummen99/d36bbea14da5fb43ccab90211d0a6135 to your computer and use it in GitHub Desktop.
Save bumbummen99/d36bbea14da5fb43ccab90211d0a6135 to your computer and use it in GitHub Desktop.
Powershell script to download Videos from Crunchyroll using YouTube-DL and browser cookies for authentification.
# Installation:
#
# Copy the script into any directory that is in your PATH variable.
# You can call it from PS using the file name i.e. crunchyroll.
#
# You can find more information on how to edit the PATH and other
# environment variables on the offical Microsoft documentation:
# https://learn.microsoft.com/en-us/windows/win32/procthread/environment-variables
#
# Usage:
# > crunchyroll -browser brave https://www.crunchyroll.com/de/watch/...
# > crunchyroll -browser brave -subtitles en-GB https://www.crunchyroll.com/de/watch/...
# > crunchyroll -browser brave -subtitles en-GB -threads 8 https://www.crunchyroll.com/de/watch/...
#
# Author: Patrick Henninger
# License: GNU GPL v3
#
Param(
# URL of the Video
[string]$url,
# Use provided "-browser <NAME>" option or ask for input
[string]$browser = $( Read-Host "Input browser to scan login cookies from (chrome,brave,opera,firefox,edge)" ),
# Use german subtitles as default
[string]$subtitles = "de-DE",
# Use half of all threads as default
[int] $threads = [math]::ceiling(((Get-ComputerInfo -Property CsProcessors).CsProcessors).NumberOfLogicalProcessors / 2)
)
# Build the command
$CMD = @('youtube-dl')
# Don't lock up the whole system by limiting threads
$CMD += "--postprocessor-args '-threads $threads'"
# Always use matroska container instead of mp4
$CMD += '--recode-video mkv'
# Include subtitles
$CMD += '--write-su'
$CMD += "--sub-lang $subtitles"
# Use cookies from browser to log in
$CMD += "--cookies-from-browser $browser"
# Add the URL to be downloaded
$CMD += "$url"
# Finalize the command by concatenating it using spaces
$FINAL = $CMD -join " "
# Execute the finalized command
Invoke-Expression $FINAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment