PK!L@g66vidl/__init__.pyfrom vidl import app def main(): return app.main()PK! /BBvidl/__main__.pyif __name__ == '__main__': from vidl import app app.main()PK!E?v[[ vidl/app.pyimport sys from colorboy import green, cyan, red, magenta, yellow, bright def log(*args, error=False, quiet=False, **named_args): vidl_text = cyan('[vidl]') if error: print(vidl_text, red('error:'), *args, **named_args) quit() elif quiet == False: print(vidl_text, *args, **named_args) script_filename = sys.argv[0] def vidl_help(): print( '') print(green( 'Usage:')) print( ' '+cyan(script_filename)+' [format] [options] ') print( '') print(green( 'Options:')) print(cyan( ' format ')+'mp3, mp4, wav or m4a. Default mp3.') print(cyan( ' --no-md ')+'Don\'t add metadata to downloaded files.') print(cyan( ' --no-smart-md ')+'Don\'t extract artist and song name from title.') print(cyan( ' -v, --verbose ')+'Display all logs.') print(cyan( ' -h, --help ')+'Display this help message.') print( '') print(green( 'Configuration:')) print( ' '+cyan(script_filename)+' config [new_value]') print( ' ') print(green( 'Available Configs:')) print(cyan( ' download_folder ')+'The folder that vidl downloads to.') print(cyan( ' output_template ')+'youtube-dl output template.') print( '') quit() def main(): if len(sys.argv) <= 1: vidl_help() elif sys.argv[1] == 'config': from vidl import config config.main() else: from vidl import dl dl.main() if __name__ == '__main__': main()PK!(wwwvidl/config.json{ "download_folder": "~/Downloads", "output_template": "%(uploader)s - %(title)s.%(ext)s", "add_metadata": true }PK!0vidl/config.pyimport sys, json, os from colorboy import green from vidl.app import vidl_help, log from pprint import pformat def path(*args, **options): DIR = os.path.dirname(os.path.abspath(__file__)) return os.path.join(DIR, *args, **options) configs = json.loads(open(path('config.json')).read()) def save(): file = open(path('config.json'), "w+") file.write(json.dumps(configs, indent=2)) file.close() def set_default_downloads_path(): if sys.platform == 'darwin': set('downloads_path', '~/Downloads') elif sys.platform == 'win32': import os os.path.join(os.getenv('USERPROFILE'), 'Downloads') def load(value): if value == 'downloads_path' and configs[value] == None: set_default_downloads_path() return configs[value] def set(key, value): if not key in configs: log('Config does not exist:', green(key), error=True) configs[key] = value save() def main(): if len(sys.argv) not in [3, 4]: vidl_help() if len(sys.argv) == 3: key = sys.argv[2] value = load(key) log('Config', key+':', green(pformat(value))) if len(sys.argv) == 4: key = sys.argv[2] value = sys.argv[3] set(key, value) save() log(key, 'was set to:', green(pformat(value)))PK!-R33 vidl/dl.pyimport sys, os import pprint; pprint = pprint.PrettyPrinter(indent=4).pprint import youtube_dl from colorboy import cyan, green from deep_filter import deep_filter from vidl import app, config from vidl.app import log class Dicty(dict): __getattr__ = dict.__getitem__ __setattr__ = dict.__setitem__ def is_int(number): try: int(number) return True except ValueError: return False def main(): options = { 'url': '', 'file_format': 'mp3', 'audio_only': True, 'no_md': False, 'no_smart_md': False, 'verbose': False, 'download_folder': config.load('download_folder'), 'output_template': config.load('output_template'), 'add_metadata': config.load('add_metadata'), } if options['download_folder'] == None: log('download_folder config has not been set. To set it, run '+green(app.script_filename+' config download_folder '), error=True) video_formats = ['mp4'] audio_formats = ['mp3', 'wav', 'm4a'] id3_metadata_formats = ['mp3'] ytdl_output_template = os.path.join(options['download_folder'], options['output_template']) # parse arguments for arg in sys.argv[1:]: if arg in audio_formats: options['audio_only'] = True options['file_format'] = arg elif arg in video_formats: options['audio_only'] = False options['file_format'] = arg elif arg in ['--no-md']: options['no_md'] = True elif arg in ['--no-smart-md']: options['no_smart_md'] = True elif arg in ['-v', '--verbose']: options['verbose'] = True elif arg in ['-h', '--help']: app.vidl_help() elif '.' in arg: options['url'] = arg else: log('Unknown argument:', arg, error=True) if len(sys.argv) <= 1: # no arguments provided app.vidl_help() if options['url'] == '': log('No URL provided', error=True) # get info log('Fetching URL info') ytdl_get_info_options = { 'outtmpl': ytdl_output_template, 'quiet': False if options['verbose'] else True, } with youtube_dl.YoutubeDL(ytdl_get_info_options) as ytdl: try: info_result = ytdl.extract_info(options['url'], download=False) except: quit() if options['verbose']: pprint(info_result) # delete None properties/indexes def callback(value): return value != None cleaned_info_result = deep_filter(info_result.copy(), callback) # restructure if 'entries' in cleaned_info_result: videos = cleaned_info_result['entries'] playlist_info = cleaned_info_result.copy() del playlist_info['entries'] else: videos = [cleaned_info_result] playlist_info = {} # generate ytdl arguments ytdl_args = [] if options['audio_only']: ytdl_args += ['-x'] ytdl_args += ['-f', 'best'] ytdl_args += ['--audio-format', options['file_format']] else: ytdl_args += ['-f', 'bestvideo+bestaudio'] ytdl_args += ['--recode-video', options['file_format']] ytdl_args += ['--audio-quality', '0'] ytdl_args += ['-o', ytdl_output_template] if options['file_format'] in ['mp3', 'm4a', 'mp4']: ytdl_args += ['--embed-thumbnail'] if not options['verbose']: ytdl_args += ['--quiet'] # ytdl_args += [options['url']] video_index = -1 for video in videos: video_index += 0 try: filename = ytdl.prepare_filename(video) except: quit() filename_split = filename.split('.') filename_split[len(filename_split)-1] = options['file_format'] filename = '.'.join(filename_split) log('Downloading') try: youtube_dl.main(ytdl_args+[video['webpage_url']]) except: pass log('Saved as', filename) if options['file_format'] in id3_metadata_formats and not options['no_md']: log('Adding metadata to file') md = Dicty() playlist = True if len(videos) > 1 else False # title / artist if 'track' in video: md.title = video['track'] elif 'title' in video: md.title = video['title'] if 'artist' in video: md.artist = video['artist'] # get artist/title from title elif 'title' in video and 'track' not in video and 'no_smart_md' not in options: if md.title.count(' - ') == 1: split_title = md.title.split(' - ') md.artist = split_title[0] md.title = split_title[1] elif 'uploader' in video: md.artist = video['artist'] if playlist: #album if 'title' in playlist_info: md.album = playlist_info['title'] elif 'playlist_title' in video: md.album = video['playlist_title'] elif 'playlist' in video and type(video['playlist']) == str: md.album = video['playlist_title'] #album_artist if 'uploader' in playlist_info: md.album_artist = playlist_info['uploader'] elif 'playlist_uploader' in video: md.album_artist = video['playlist_uploader'] # track_number if 'playlist_index' in video: md.track_number = video['playlist_index'] else: md.track_number = video_index+1 # track_count if 'n_entries' in video: md.track_count = video['n_entries'] else: md.track_count = len(videos) # year if 'release_date' in video and is_int(video['release_date'][:4]): md.year = video['release_date'][:4] elif 'publish_date' in video and is_int(video['publish_date'][:4]): md.year = video['publish_date'][:4] elif 'upload_date' in video and is_int(video['upload_date'][:4]): md.year = video['upload_date'][:4] import md as md_module md_module.add_metadata(filename, md) PK!>  vidl/md.pyfrom mutagen.id3 import ID3, TIT2, TALB, TPE1, TPE2, COMM, USLT, TCOM, TCON, TDRC import pprint; pprint = pprint.PrettyPrinter(indent=4).pprint def add_metadata(filename, md): tags = ID3(filename) print(filename) if 'title' in md: tags["TIT2"] = TIT2(encoding=3, text=md.title) if 'artist' in md: tags["TPE1"] = TPE1(encoding=3, text=md.artist) if 'album' in md: tags["TALB"] = TALB(encoding=3, text=md.album) if 'album_artist' in md: tags["TPE2"] = TPE2(encoding=3, text=md.album_artist) if 'track_number' in md: track_number = str(md.track_number) if 'track_count' in md: track_number += '/'+str(md.track_count) tags["TRCK"] = TRCK(encoding=3, text=track_number) if 'genre' in md: tags["TCON"] = TCON(encoding=3, text=md.genre) if 'year' in md: tags["TDRC"] = TDRC(encoding=3, text=md.year) pprint(md) tags.save(filename)PK!H;A%&%vidl-3.0.0.dist-info/entry_points.txtN+I/N.,()*LɱzVy\\PK!HW"TTvidl-3.0.0.dist-info/WHEEL A н#J."jm)Afb~ ڡ5 G7hiޅF4+-3ڦ/̖?XPK!Hb vidl-3.0.0.dist-info/METADATAXms6_8=#QNWq'XN:wOx(EssYd^gHb쳻z'/OX՘L_$y-l)*~2i뚛]\+fs#ǜf^J =m!M[Y9nֺuT Ű3;hDM*ur)s,~|obҦNɠ6ZZ''-<3cM85՘vat1eF\ɵG+ј:H_iŭPwej.pDʧ|o>7a3iݘ8 qp"?{ N_B49d_<.ɽHg"jrÛu`9Ս)Iw.3% VVGqJkz%0ݸ xt͝y-27o-YQCΐ a$UxQ:kRLL疕UEneáúȘ3E.4ɜt,!/Xd3#;?^_$5_W8;y+IBc5mk>hߝ),{]&Aw .!B1Aǩ(^A%Pӈɥ}  >_HUTR֤ ed"wU kF,F̼ke=wV4O]el(Yr%9W1خya´aIgJ SdFTV(HN̴J3/ )嬗\@5͏t~ h5l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