Package: yt-audio
yt-audioA simple, configurable, cross-platform youtube-dl wrapper for downloading and managing youtube audio (with added features).InstallationRequiresPython3(>=3.5),youtube-dlandffmpeg/avconvas dependencies.yt-audio can be installed viapip. Arch Linux users can useAURas well.$ [sudo] pip3 install --upgrade yt-audioDescription and Featuresyt-audio is a command-line program that is used download and manage audio from youtube.com. It is a youtube-dl wrapper program, which means it uses youtube-dl as backend for downloading audio. yt-audio tries to make audio/playlist management easy for users. It is cross-platform (Windows/Linux/MacOS).FeaturesConfigure/Setup your own command-line arguments for managing titles/playlists (Seeusagebelow)Ability to save each audio/playlist to a different directory (directory specified in argument).Option to keep track of already-downloaded playlist titleswith or without archive file.Manage single/playlist audio(s).Usageusage: YTAudio.py [OPTIONS] REQUIRED_ARGS

A simple, configurable youtube-dl wrapper for downloading and managing youtube audio.

Required Arguments (Any/all):
URL[::DIR]            Video/Playlist URL with (optional) save directory [URL::dir]
-e, --example1        Example playlist [Custom]
--all                 All [Custom] Arguments

Optional Arguments:
-h, --help            show this help message and exit
-v, --version         show version and exit
--use-archive         use archive file to track downloaded titles
--use-metadata        use metadata to track downloaded titles
--output-format [OUTPUT_FORMAT]
                        File output format
--ytdl-args [YTDL_ADDITIONAL_ARGS]
                        youtube-dl additional argumentsyt-audio requires either URL or custom argument(s) (or both) as mandatory input(s).Custom Argumentsyt-audio gives user the ability to setup their own custom arguments for managing/synchronizing audio/playlists. Custom arguments can be configured in yt-audio's(config.ini)configuration file.NOTE (pip users): The user, if required, will have to copy theconfiguration fileas it is not copied during installation.Unix/Linux Users:The default config location is$XDG_CONFIG_HOME/yt-audio/directory. In case$XDG_CONFIG_HOMEis not set, the file can be placed in$HOME/.config/yt-audio/directory.Windows Users:The default config location isC:\Users\<user>\.config\yt-audioSetting up custom argumentsThe config fileconfig.inihas URL_LIST[] option where users can specify arguments with corresponding URL and (optional) save directory. It's format is as follows:URL_LIST = [
                # "['-short_arg1','--long_arg1','Help Text/Description']::URL::PATH"

                # PATH (optional) specifies output directory for that particular playlist
                # PATH should be absoulte directory path
                # URL: Complete youtube title/playlist URL
                # These arguments are visible in --help

                # "['-e','--example1','Example playlist']::URL::PATH",
           ]URL_LIST takes comma-separated string values. Each string value is formed from 3 components:CLI Argument - Argument to register. It is written in form: ['-short_arg','--long_arg','Help Text/Description']URL: Youtube playlist/title URL.PATH (optional): Path where this particular playlist/title will be saved. Provide absolute PATH here.All custom arguments are visible in --help [$ yt-audio --help]The default save PATH is$HOME/Music.  PATH can be configured by user in config file (OUTPUT_DIRECTORY = <dir>). For playlists, one more directory of <PlaylistName> is created where all playlist records are saved.Keeping track of downloaded titles/playlistsyt-audio has an added feature of keeping track of audio files usingfile's metadata. This removes the requirement of additional archive file to store title(s) info (option provided by youtube-dl).User can specify any of the two ways to keep track of downloaded titles. (By default, downloaded titles arenot tracked)Using File MetadataTo use file's metadata, pass--use-metadataargument to yt-audio. To use metadata everytime, you can setUSE_METADATA = 1in config file. Metadata method requires following to work:--add-metadataargument to youtube-dl (--add-metadataargument is added by yt-audio by default. If you don't want this, you can re-configure youtube-dl command in config).Known limitations of using metadata methodI have tried this method with both MP3 and M4A format. MP3 works fine. M4a does not work.Using Archive FileTo use archive file method, pass--use-archiveargument to yt-audio. To use archive file everytime with yt-audio, you can setUSE_ARCHIVE = 1in config file. This will create 'records.txt' file in title's download location.--use-archiveflag simply passes youtube-dl's--download-archive FILEargument to youtube-dl. You can pass your own filename to youtube-dl as well with--ytdl-args \"--download-archive FILE\". More info about'--ytdl-args'argument.# Enable metadata
$ yt-audio --use-metadata [URL/custom_args]

# Enable archive file - creates records.txt file
$ yt-audio --use-archive [URL/custom_args]

# Enable archive file - creates archive.txt file
$ yt-audio --ytdl-args \"--download-archive FILE\" [URL/custom_args]If both metadata and archive file are enabled, archive file method is usedTitle/Playlist-specific PATHUser can also specify any arbitrary path for a particular playlist/title. This PATH can be specified as URL::PATH. If PATH is not provided, PATH from config file is used. If no path is present in config,$HOME/Musicpath is usedChanging output formatDownloaded file's output format can be specified with--output-formatargument.Output Template. Default output format is"%(title)s.%(ext)s"Passing additional paramaters to youtube-dlyt-audio gives user the flexibility to pass additional parameters to youtube-dl directly from command-line. Additional arguments can be provided with--ytdl-argumentsyt-audio argument. Arguments passed toytdl-argumentsare passed as-it-is to youtube-dl.$ yt-audio `--ytdl-args \"--download-archive FILE --user-agent UA\"`NOTE:Make sure to escape double-quotes"when passing arguments to--ytdl-args. Else the arguments passed to--ytdl-argswill be read as input arguments to yt-audio.Modifying default youtube-dl/helper commandsThe commands used by yt-audio can be modified from config file. Unusual parameters might break the program. If the parameter is legit and should have (ideally) worked but it didn't, pleaseraise an issue.Usage Examples# Synchronizes/downloads --custom1 and --custom2 custom argument URLs and download specified URL as well.
$ yt-audio --custom1 --custom2 https://youtube.com/playlist?list=abcxyz

# Saves playlist to /my/path/p1/<PlaylistName>/ and single audio to /some/another/path
$ yt-audio https://youtube.com/playlist?list=abcxyz::/my/path/p1 https://www.youtube.com/watch?v=abcxyz::/some/another/path

# Adding additional youtube-dl arguments
# This will append additional arguments to youtube-dl download command
$ yt-audio --ytdl-args \"arg1 arg2\" https:youtube.com/abc https://youtube.com/xyz::DIR

# Different output format
$ yt-audio --output-format "%(display_id)s.%(ext)s" https://youtube.com/...yt-audo defaultsThe following commands are used by yt-audio to download and manage audio. The commands are configurable using config file.youtube-dl audio download# (-x --print-json -o "$OUTPUT$" $URL$) are mandatory
$ youtube-dl -x --print-json --audio-format mp3 --audio-quality 0 --add-metadata --embed-thumbnail -o "$OUTPUT$" $URL$get playlist/URL info$ youtube-dl --flat-playlist -J $PLAYLIST_URL$get file's metadata(used when downloaded titles are tracked using metadata)$ ffprobe -v quiet -print_format json -show_format -hide_banner "$PATH$"LimitationsKeeping track of downloaded tracks works with youtube.com only (for now).Bugs/IssuesPleasecreateissue for the same.
I'm open to suggestions as well :)ContactFeel free get in touch with me viaTwitterorEmail.LicenseMIT