1""" Module for holding globals that are needed throught mps-youtube. """ 2 3import os 4import sys 5import collections 6 7from . import c, paths 8from .playlist import Playlist 9 10 11volume = None 12transcoder_path = "auto" 13delete_orig = True 14encoders = [] 15muxapp = False 16meta = {} 17artist = "" # Mostly used for scrobbling purposes 18album = "" # Mostly used for scrobbling purposes 19scrobble = False 20scrobble_queue = [] 21lastfm_network = None 22detectable_size = True 23command_line = False 24debug_mode = False 25preload_disabled = False 26ytpls = [] 27mpv_version = 0, 0, 0 28mpv_options = None 29mpv_usesock = False 30mplayer_version = 0 31mprisctl = None 32browse_mode = "normal" 33preloading = [] 34# expiry = 5 * 60 * 60 # 5 hours 35no_clear_screen = False 36no_textart = False 37max_retries = 3 38max_cached_streams = 1500 39username_query_cache = collections.OrderedDict() 40model = Playlist(name="model") 41last_search_query = (None, None) 42current_page = 0 43result_count = 0 44rprompt = None 45active = Playlist(name="active") 46userpl = {} 47userhist = {} 48pafs = collections.OrderedDict() 49streams = collections.OrderedDict() 50pafy_pls = {} # 51last_opened = message = content = "" 52suffix = "3" # Python 3 53OLD_CFFILE = os.path.join(paths.get_config_dir(), "config") 54CFFILE = os.path.join(paths.get_config_dir(), "config.json") 55TCFILE = os.path.join(paths.get_config_dir(), "transcode") 56OLD_PLFILE = os.path.join(paths.get_config_dir(), "playlist" + suffix) 57PLFILE = os.path.join(paths.get_config_dir(), "playlist_v2") 58PLFOLDER = os.path.join(paths.get_config_dir(), "playlists") 59OLDHISTFILE = os.path.join(paths.get_config_dir(), "play_history") 60HISTFILE = os.path.join(paths.get_config_dir(), "play_history.m3u") 61CACHEFILE = os.path.join(paths.get_config_dir(), "cache_py_" + sys.version[0:5]) 62READLINE_FILE = None 63PLAYER_OBJ = None 64categories = { 65 "film": 1, 66 "autos": 2, 67 "music": 10, 68 "sports": 17, 69 "travel": 19, 70 "gaming": 20, 71 "blogging": 21, 72 "news": 25 73} 74playerargs_defaults = { 75 "mpv": { 76 "msglevel": {"<0.4": "--msglevel=all=no:statusline=status", 77 ">=0.4": "--msg-level=all=no:statusline=status"}, 78 "title": "--force-media-title", 79 "fs": "--fs", 80 "novid": "--no-video", 81 "ignidx": "--demuxer-lavf-o=fflags=+ignidx", 82 "geo": "--geometry"}, 83 "mplayer": { 84 "title": "-title", 85 "fs": "-fs", 86 "novid": "-novideo", 87 # "ignidx": "-lavfdopts o=fflags=+ignidx".split() 88 "ignidx": "", 89 "geo": "-geometry"}, 90 "vlc": { 91 "title": "--meta-title"} 92 } 93argument_commands = [] 94commands = [] 95 96text = { 97 "exitmsg": ("*mps-youtube - *https://github.com/mps-youtube/mps-youtube*" 98 "\nReleased under the GPLv3 license\n" 99 "(c) 2014, 2015 np1 and contributors*\n"""), 100 "exitmsg_": (c.r, c.b, c.r, c.w), 101 102 # Error / Warning messages 103 104 'no playlists': "*No saved playlists found!*", 105 'no playlists_': (c.r, c.w), 106 'pl bad name': '*&&* is not valid a valid name. Ensure it starts with' 107 ' a letter or _', 108 'pl bad name_': (c.r, c.w), 109 'pl not found': 'Playlist *&&* unknown. Saved playlists are shown ' 110 'above', 111 'pl not found_': (c.r, c.w), 112 'pl not found advise ls': 'Playlist "*&&*" not found. Use *ls* to ' 113 'list', 114 'pl not found advise ls_': (c.y, c.w, c.g, c.w), 115 'pl empty': 'Playlist is empty!', 116 'advise add': 'Use *add N* to add a track', 117 'advise add_': (c.g, c.w), 118 'advise search': 'Search for items and then use *add* to add them', 119 'advise search_': (c.g, c.w), 120 'no data': 'Error fetching data. Possible network issue.' 121 '\n*&&*', 122 'no data_': (c.r, c.w), 123 'use dot': 'Start your query with a *.* to perform a search', 124 'use dot_': (c.g, c.w), 125 'cant get track': 'Problem playing last item: *&&*', 126 'cant get track_': (c.r, c.w), 127 'track unresolved': 'Sorry, this track is not available', 128 'no player': '*&&* was not found on this system', 129 'no player_': (c.y, c.w), 130 'no pl match for rename': '*Couldn\'t find matching playlist to ' 131 'rename*', 132 'no pl match for rename_': (c.r, c.w), 133 'invalid range': "*Invalid item / range entered!*", 134 'invalid range_': (c.r, c.w), 135 '-audio': "*Warning* - the filetype you selected (&&) has no audio!", 136 '-audio_': (c.y, c.w), 137 'no mix': 'No mix is available for the selected video', 138 'mix only videos': 'Mixes are only available for videos', 139 'invalid item': '*Invalid item entered!*', 140 'duplicate tracks': '*Warning* - duplicate track(s) && added to ' 141 'playlist!', 142 'duplicate tracks_': (c.y, c.w), 143 144 # Info messages.. 145 146 'select mux': ("Select [*&&*] to mux audio or [*Enter*] to download " 147 "without audio\nThis feature is experimental!"), 148 'select mux_': (c.y, c.w, c.y, c.w), 149 'pl renamed': 'Playlist *&&* renamed to *&&*', 150 'pl renamed_': (c.y, c.w, c.y, c.w), 151 'pl saved': 'Playlist saved as *&&*. Use *ls* to list playlists', 152 'pl saved_': (c.y, c.w, c.g, c.w), 153 'pl loaded': 'Loaded playlist *&&* as current playlist', 154 'pl loaded_': (c.y, c.w), 155 'pl viewed': 'Showing playlist *&&*', 156 'pl viewed_': (c.y, c.w), 157 'pl help': 'Enter *open <name or ID>* to load a playlist', 158 'pl help_': (c.g, c.w), 159 'added to pl': '*&&* tracks added (*&&* total [*&&*]). Use *vp* to ' 160 'view', 161 'added to pl_': (c.y, c.w, c.y, c.w, c.y, c.w, c.g, c.w), 162 'added to saved pl': '*&&* tracks added to *&&* (*&&* total [*&&*])', 163 'added to saved pl_': (c.y, c.w, c.y, c.w, c.y, c.w, c.y, c.w), 164 'song move': 'Moved *&&* to position *&&*', 165 'song move_': (c.y, c.w, c.y, c.w), 166 'song sw': ("Switched item *&&* with *&&*"), 167 'song sw_': (c.y, c.w, c.y, c.w), 168 'current pl': "This is the current playlist. Use *save <name>* to save" 169 " it", 170 'current pl_': (c.g, c.w), 171 'help topic': (" Enter *help <topic>* for specific help:"), 172 'help topic_': (c.y, c.w), 173 'songs rm': '*&&* tracks removed &&', 174 'songs rm_': (c.y, c.w), 175 'mkp empty': "*&&* is either empty or doesn't exist", 176 'mkp empty_': (c.b, c.r), 177 'mkp parsed': "*&&* entries found in *&&*", 178 'mkp parsed_': (c.g, c.w, c.b, c.w), 179 'mkp finding': "Finding the best match for *&&* ...", 180 'mkp finding_': (c.y, c.w), 181 'mkp desc unknown': "Unknown tabletype, *do a new search*", 182 'mkp desc unknown_': (c.y, c.w), 183 'mkp desc which data': "Which *tracks* to include?", 184 'mkp desc which data_': (c.y, c.w), 185 'mkp no valid': "*No valid tracks found in that description*", 186 'mkp no valid_': (c.y, c.w)} 187