{ "info": { "author": "Ray Douglass", "author_email": "ray@raydouglass.com", "bugtrack_url": null, "classifiers": [], "description": "# Media Management Scripts\n\nThis is a collection of command line tools for managing media files such as movies or TV shows.\n\n## Installation\n\nInstall the tools:\n\n`pip install media_management_scripts`\n\nYou also need to install other programs:\n\n### MacOS\n\n`brew install ffmpeg dialog`\n\n### Ubuntu\n\n`apt install ffmpeg dialog`\n\n### TVDB\n\nIf you want to use TVDB for some commands, create an account on and create API keys [here](https://www.thetvdb.com/member/api)\n\nCreate a file `~/.config/tvdb/tvdb.ini` with contents:\n\n```ini\n[tvdb]\nusername = \nuserkey = \napikey = \n```\n\n# Usage\n\nPass `--help` to the subcommands for detailed help. Major features are explained in detail below.\n\nMost commands that rename or move files have a dry-run mode (`-n` or `--dry-run`) which will output the actions so you can verify the results.\n\n## Main tools\n__[convert](#convert)__\n\n__[metadata](#metadata)__\n\n__[rename](#rename)__\n\n__[search](#search)__\n\n__[tv-rename](#tv-rename)__\n \n\nHelp output\n```\nusage: manage-media [-h] [-v]\n\nSub commands\n combine-subtitles Combine a video files with subtitle file\n combine-all Combine a directory tree of video files with subtitle\n file\n concat-mp4 Concat multiple mp4 files together\n convert Convert a file\n find-episodes Find Season/Episode/Part using file names\n itunes Attempts to rename iTunes episodes to the standard\n Plex format.\n metadata Show metadata for a file\n compare Compare metadata between files\n compare-directory Show metadata for a file\n movie-rename Renames a file based on TheMovieDB\n rename Renames a set of files to the specified template\n select-streams Extract specific streams in a video file to a new file\n split Split a file\n subtitles Convert subtitles to SRT\n tv-rename Renames files in a directory to sXXeYY. Can also use\n TVDB to name files ( - SxxeYY - )\n\noptional arguments:\n -h, --help show this help message and exit\n -v, --version Display version\n```\n\n## convert\n\nConvert a video file to different video or audio codecs\n\n#### Examples:\n- Convert to H.264\n - `manage-media convert --video-codec h264 `\n- Convert to HEVC/H.265:\n - `manage-media convert --video-codec hevc `\n- Convert to HEVC with AC3 audio:\n - `manage-media convert --video-codec hevc --audio-codec ac3 `\n- Convert to HEVC, but don't convert audio:\n - `manage-media convert --vc hevc --ac copy `\n- Scale to 480p\n - `manage-media convert --scale 480`\n- Convert to H.264 and remove interlacing (such as on mpeg2 DVDs)\n - `manage-media convert --vc h264 --deinterlace`\n- Convert a whole directory of files\n - `manage-media convert --vc h264 --bulk `\n\n## metadata\n\nGet a simple output of metadata for a file. Or get lots of metadata in json format\n\n#### Simple output\n`manage-media metadata `\n```\nBattlestar Galatica (2003) - s00e01 - Battlestar Galactica The Miniseries (1).mkv\n Directory: /Volumes/Media/TV Shows/Battlestar Galactica/Season 0/\n Title: Battlestar Galactica: Season 1 (Disc 1)\n Size: 6.8GB\n Format: matroska,webm\n Duration: 1h34m39s\n Bitrate: 10117 Kbps\n Video: h264 8 bit (1920x1080)\n Audio:\n aac (eng, 5.1)\n Subtitles: eng, spa, fra\n Ripped: True\n```\n\n#### Json\n`manage-media metadata --json `\n```json\n{\n \"file\": \"/Volumes/Media/TV Shows/Battlestar Galactica/Season 0/Battlestar Galatica (2003) - s00e01 - Battlestar Galactica The Miniseries (1).mkv\",\n \"title\": \"Battlestar Galactica: Season 1 (Disc 1)\",\n \"duration\": 5679.362,\n \"duration_str\": \"1h34m39s\",\n \"size\": 7354722701,\n \"size_str\": \"6.8GB\",\n \"resolution\": \"HIGH_DEF\",\n \"bit_rate\": 10359928,\n \"bit_rate_str\": \"10117 Kbps\",\n \"ripped\": true,\n \"format\": \"matroska,webm\",\n \"format_long_name\": \"Matroska / WebM\",\n \"mime_type\": \"video/x-matroska\",\n \"tags\": {\n \"title\": \"Battlestar Galactica: Season 1 (Disc 1)\",\n \"RIPPED\": \"true\",\n \"ENCODER\": \"Lavf57.56.100\"\n },\n \"video_streams\": [ ... ],\n \"audio_streams\": [ ... ],\n \"subtitle_streams\": [ ... ],\n \"other_streams\": [ ... ],\n \"chapters\": [ ... ],\n \"interlace\": null\n}\n```\n\n## rename\n\nA flexible tool to rename files\n\nRename files based on a template.\n\nTemplates can include variables or expressions by surrounding with ${...}. Functions can be called like `${upper(i)}` or `${i | upper}`.\n\nThe following variables are available:\n * `i`/`index` - The index of the current file being renamed\n * `wo_ext` - The file name basename without the extension\n * `ext` - The file extension of the current file (without '.')\n * `filename` - The filename of the current file (basename)\n * `re`/`regex` - A list of regex match groups (use `re[0]`, `re[1]`, etc)\n\nThe following functions are available:\n * `upper` - Upper cases the input\n * `lower` - Lower cases the input\n * `ifempty(a, b, c)` - If a is empty or null, then b, otherwise c\n * `lpad(a, b:int)` - Left pads a to length b (defaults to 2+) with spaces\n * `zpad(a, b:int)` - Left pads a to length b (defaults to 2+) with zeros\n\n`lpad`/`zpad` - By default pads to at least 2 characters. If there are 100+ files, then 3 characters, 1000+ files, then 4 characters, etc.\n\nRegular Expressions:\nIf a regex is included, the match groups (0=whole match, >0=match group) are available in a list 're' or 'regex'.\nEach match group is converted to an int if possible, so a zero padded int will lose the zeros.\n\nExamples:\n```\nInput: S02E04.mp4\nRegex: S(\\d+)E(\\d+)\n\nTemplate: 'Season ${re[1]} Episode ${re[2]}.{ext}'\nResult: 'Season 2 Episode 4.mp4'\n\nTemplate: 'Season ${re[1] | zpad} Episode ${zpad(re[2], 3)}.{ext}'\nResults: 'Season 02 Episode 004.mp4'\n```\n```\nInput: whatever.mp4\nRegex: S(\\d+)E(\\d)\nTemplate: 'Season ${ifempty(re[1], 'unknown', re[1])} Episode ${re[2]}.{ext}'\nResult: 'Season unknown Episode .mp4'\n```\n\n## search\n\nSearches a directory for video files matching parameters. Note: this can take a LONG time as it has to read the metadata for each file.\nYou can speed up multiple searches in the same directory with `--db