README.md (4750B)
1 2 # sya 3 4 **sya - split youtube audio**, download, convert & split audio from youtube videos into multiple audio tracks using 'yt-dlp' and 'ffmpeg'. 5 6 --- 7 8 ## sya.py 9 10 This is the base Python script, which contains all the functionality: 11 12 sya.py [OPTIONS] TRACKLIST 13 14 ### OPTIONS 15 16 ``` 17 -h, --help 18 show this help message and exit 19 20 -o [PATH], --output [PATH] 21 specify the directory to write output files to (default: ./out) 22 23 -f [FORMAT], --format [FORMAT] 24 specify the --audio-format argument to pass to yt-dlp (default: mp3) 25 26 -q [QUALITY], --quality [QUALITY] 27 specify the --audio-quality argument to pass to yt-dlp (default: 320K) 28 29 --yt-dlp [PATH] 30 path of the "yt-dlp" binary to use 31 32 --ffmpeg [PATH] 33 path of the "ffmpeg" binary to use 34 35 -k, --keep 36 keep any files removed during processing (full video/audio file) 37 ``` 38 39 ### TRACKLIST 40 41 **TRACKLIST** should be the filepath of a UTF-8 text file that has the URL of the video to download to audio track of on line 1. 42 Every line after this should be the track name and timestamp of each track, note that the timestamp is *where the track starts*. 43 44 Regex is used to parse the tracks (timestamp and name), it tries to be fairly accomodating but isn't perfect - so here are a few rules: 45 46 - Timestamps can be before or after the track name. 47 - Timestamps can be wrapped in `[]` or `()`. 48 - Timestamps can be `MM:SS` or `HH:MM:SS`. 49 - Timestamps can be split using `:` or `.`. 50 51 <details> 52 <summary>Example Tracklist</summary> 53 <pre> 54 https://www.youtube.com/watch?v=LbjcaMAhJRQ 55 Sneaky Snitch (0:00) 56 Fluffing a Duck (2:16) 57 Cipher (3:24) 58 Scheming Weasel (7:15) 59 Carefree (8:44) 60 Thatched Villagers (12:09) 61 Monkeys Spinning Monkeys (16:15) 62 Wallpaper (18:20) 63 Pixel Peeker Polka (21:59) 64 Killing Time (25:21) 65 Hitman (28:46) 66 The Cannery (32:07) 67 Cut and Run (35:09) 68 Life of Riley (38:44) 69 Quirky Dog (42:39) 70 The Complex (45:08) 71 Hyperfun (49:35) 72 Black Vortex (53:29) 73 Rock on Chicago (56:19) 74 Volatile Reaction (57:58) 75 On the Ground (1:00:44) 76 Wagon Wheel (electronic) (1:03:23) 77 Call to Adventure (1:08:26) 78 Hustle (1:12:33) 79 Cupids Revenge (1:14:34) 80 Dirt Rhodes (1:16:20) 81 Rhinoceros (1:18:20) 82 Who Likes to Party (1:21:43) 83 Spazzmatica Polka (1:26:01) 84 </pre> 85 </details> 86 87 ### Install 88 89 It's a Python script, so there are many ways to install it. 90 91 Here's one that should work on *any* system: 92 93 python3 ./setup.py install --user --record install.txt 94 95 To **uninstall**, just remove all files recorded to *./install.txt*. 96 97 --- 98 99 ## sya-pyqt 100 101 Some people don't like the cli and I wanted to play with PyQt, so sya-pyqt wraps a nice GUI around the *sya.py* runtime. 102 103 ![screenshot](./screenshot.PNG "sya-pyqt on Windows") 104 105 ### Development 106 107 Working on or building requires *PyQt5*, this can be installed with `pip install PyQt5`. 108 109 To run *sya-pyqt*, you don't need to build a binary everytime, you can just run `python ./sya-pyqt.py`. 110 111 ### Building 112 113 [pyinstaller](https://pyinstaller.org) is used to build a portable binary for sya-pyqt for easy distribution. 114 115 **POSIX (Linux, MacOS, BSD)** 116 117 FFMPEG="<filepath to ffmpeg>" \ 118 YTDLP="<filepath to yt-dlp>" \ 119 pyinstaller ./src/sya-pyqt.py -F --windowed --add-data "./doc/HELP.md:." --add-data "./res/folder.png:." --add-data "./res/file.png:." --add-data "./res/sya.png:." --add-data "$FFMPEG:." --add-data "$YTDLP:." 120 121 **Windows** 122 123 $FFMPEG="<filepath to ffmpeg.exe>" 124 $YT_DLP="<filepath to yt-dlp.exe>" 125 pyinstaller .\src\sya-pyqt.py -F --windowed --add-data ".\doc\HELP.md;." --add-data ".\res\folder.png;." --add-data ".\res\file.png;." --add-data ".\res\sya.png;." --add-data "$FFMPEG;." --add-data "$YT_DLP;." 126 127 128 **IMPORTANT NOTES** 129 130 - Make sure you have the latest *yt-dlp* binary available, the filepath to this should replace *$YT-DLP*. 131 - Make sure you have the latest *ffmpeg* binary available, the filepath of this should replace *$FFMPEG*. 132 - In some cases, I've found the path of PyQt5 has had to be explicitly given to *pyinstaller*: 133 `--path <site-packages filepath>\PyQt5` 134 - You might want to add an icon to the binary, to do this install [Pillow](https://python-pillow.org/) and add `--icon "sya.png"` to the build command. 135 136 137 --- 138 139 ## Thanks 140 141 These two tools do all the heavy lifting: 142 - youtube-dl (https://ytdl-org.github.io/youtube-dl/) 143 - ffmpeg (https://ffmpeg.org) 144 145 And the cool folder & file icons used in 'sya-pyqt' are from the Palemoon MicroMoon theme: 146 https://repo.palemoon.org/Lootyhoof/micromoon 147 148 149 ## Disclaimer 150 151 It should go without saying, don't use this for pirating music. Get nice high-quality, properly tagged audio tracks from official services (shoutout to Bandcamp). 152 The tool was originally written to download radio mixes and ambient soundtracks for a DnD group. 153 154 ## Authors 155 156 - gearsix