Check-in [8bcd2bc3d5]
Overview
Comment: | Use bold tags for config descriptions instead of Unicode workaround. Group flags by category: basic, extra, verbose to filter out uneeded ones. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
8bcd2bc3d54ee6959eb2b48be811d905 |
User & Date: | mario on 2017-01-25 19:15:33 |
Other Links: | manifest | tags |
Context
2017-02-12
| ||
20:57 | new plugin: radiolist.net check-in: a763653e6b user: mario tags: trunk | |
2017-01-25
| ||
19:15 | Use bold tags for config descriptions instead of Unicode workaround. Group flags by category: basic, extra, verbose to filter out uneeded ones. check-in: 8bcd2bc3d5 user: mario tags: trunk | |
19:14 | Support for markup in checkbox config options. check-in: ecbafb9a1c user: mario tags: trunk | |
Changes
Modified contrib/recordflags.py from [cd11ba7686] to [c265dd52ec].
1 2 3 4 | # encoding: utf-8 # api: streamtuner2 # title: Recording options # description: Allows to set streamripper/fIcy options before recording | | > | | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | # encoding: utf-8 # api: streamtuner2 # title: Recording options # description: Allows to set streamripper/fIcy options before recording # version: 0.8 # depends: streamtuner2 > 2.2.0 # conflicts: continuous_record # priority: optional # config: # { name: recordflags_auto, type: bool, value: 1, description: Apply options automatically once saved. } # { name: recordflags_row, type: select, value: record_flags, select: "record_flags|extras", description: Station field for saved options. } # { name: recordflags_dir, type: str, value: "", description: Default output directory. } # { name: recordflags_extra, type: select, value: basic, select: basic|extra|verbose, description: Detailed tool options. } # type: handler # category: ui # # Hijacks the โ record button, presents an option dialog to set various # streamripper options. Allows to set an output directory or single-file # recording for example. # # Reuses the known option scheme from the config window. Which is perhaps # less pretty than a custom dialog, but allows to set options for different # download/recording tools: streamripper, fPls, youtube-dl, wget. # # Note that predefining -flags in the Apps/Recording config table might # conflict with per-stream options. In particular avoid a -d directory # default for streamripper; and use this pluginsยด option instead. # # You can set the "detailed" option to show more tool options. Per default # only the most useful flags are shown. # # ToDo: # โ override main.record() instead of action.record # โ eventually strip defaults such as `-d ../dir` from conf.record; # using action append= param now, thus no rewriting of assoc dict # |
︙ | ︙ | |||
54 55 56 57 58 59 60 61 | "streamripper": { "title": "streamripper", "priority": "required", "type": "app", "category": "recording", "version": "1.64.6", "description": "Standard radio/stream recording tool", "config": [ | > | | | | | > | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | "streamripper": { "title": "streamripper", "priority": "required", "type": "app", "category": "recording", "version": "1.64.6", "description": "Standard radio/stream recording tool", "doc": "streamripper is the standard tool for recording and extracting songs from internet radio stations. It does have a plethora of options, some of which are available here:", "config": [ #{ "name": "A", "arg": "-A", "type": "bool", "description": "<b>-A</b> Don't split individual tracks/MP3s", "value": False }, { "name": "Aa", "arg": "-A -a", "type": "str", "description": "<b>-a</b> Single MP3 output filename. (Instead of splitting by song.)", "value": "" }, { "name": "dir", "arg": "-d", "type": "str", "description": "<b>-s</b> Destination directory", "value": "" }, { "name": "D", "arg": "-D", "type": "str", "description": "<b>-D</b> Filename pattern", "value": "" }, { "name": "s", "arg": "-s", "type": "bool", "description": "<b>-s</b> No subdirectories for each stream", "value": False }, { "name": "o", "arg": "-o", "type": "select", "description": "<b>-o</b> Incomplete track overwriting", "select": "|always|never|larger|version", "value": "" }, { "name": "t", "arg": "-t", "type": "bool", "description": "<b>-t</b> Never overwrite incomplete tracks", "value": False, "category": "extra" }, { "name": "T", "arg": "-T", "type": "bool", "description": "<b>-T</b> Truncate duplicated incompletes", "value": False, "category": "extra" }, { "name": "l", "arg": "-l", "type": "int", "description": "<b>-l</b> Seconds to record", "value": 0, "max": 7*24*3600 }, { "name": "M", "arg": "-M", "type": "int", "description": "<b>-M</b> Max megabytes to record", "value": 512 }, { "name": "xs2", "arg": "--xs2", "type": "bool", "description": "<b>--xs2</b> New pause detection algorithm", "value": False }, { "name": "xsnone", "arg": "--xs-none", "type": "bool", "description": "<b>--xs-none</b> No silence splitting", "value": False, "category": "extra" }, { "name": "i", "arg": "-i", "type": "bool", "description": "<b>-i</b> Don't add any ID3 tags", "value": False, "category": "extra" }, { "name": "id3v1", "arg": "--with-id3v1", "type": "bool", "description": "<b>--with-id3v1</b> Add ID3v1 tags", "value": False }, { "name": "noid3v2", "arg": "--without-id3v2", "type": "bool", "description": "<b>--without-id3v2</b> Omit ID3v2 tags", "value": False, "category": "verbose" }, { "name": "cs_fs", "arg": "--codeset-filesys", "type": "str", "description": "Charset filesystem", "value": "", "category": "extra" }, { "name": "cs_id3", "arg": "--codeset-id3", "type": "str", "description": "Charset ID3 tags", "value": "", "category": "extra" }, { "name": "u", "arg": "-u", "type": "str", "description": "<b>-u</b> User-agent (browser id)", "value": "", "category": "extra" }, { "name": "p", "arg": "-p", "type": "str", "description": "<b>-p</b> Url for HTTP proxy to use", "value": "", "category": "extra" }, { "name": "r", "arg": "-r", "type": "str", "description": "<b>-r</b> Relay server 'localhost:8000'", "value": "", "category": "extra" }, { "name": "m", "arg": "-m", "type": "int", "description": "<b>-m</b>Timeout for stalled connection", "value": 15, "category": "verbose" }, { "name": "debug", "arg": "--debug", "type": "bool", "description": "<b>--debug</b> Extra verbosity", "value": False, "category": "verbose"}, ] }, "fPls": { "title": "fPls/fIcy", "priority": "required", "type": "app", "category": "recording", "version": "1.0.19", "description": "Alternative station recording tool", "config": [ { "name": "max", "arg": "-M", "type": "int", "description": "<b>-M</b> Maximum cumulative playing time", "value": 0 }, { "name": "loop", "arg": "-L", "type": "int", "description": "<b>-L</b> Maximum playlist loops", "value": 0 }, { "name": "retry", "arg": "-R", "type": "int", "description": "<b>-R</b> Maximum per-stream retries", "value": 0 }, { "name": "redir", "arg": "-l", "type": "int", "description": "<b>-l</b> Redirect follow limit", "value": 0 }, { "name": "fail", "arg": "-T", "type": "int", "description": "<b>-T</b> Wait time after failure", "value": 0 }, { "name": "daemon", "arg": "-i", "type": "int", "description": "<b>-i</b> Max network idle seconds", "value": 0 }, { "name": "authfn", "arg": "-a", "type": "str", "description": "<b>-a</b> HTTP auth file (user:pass)", "value": "" }, { "name": "verbose", "arg": "-v", "type": "bool", "description": "<b>-v</b> Verbose mode", "value": False }, { "name": "daemon", "arg": "-d", "type": "str", "description": "<b>-d</b> Daemon mode: log file", "value": "" }, { "name": "ficy", "arg": "-P", "type": "str", "description": "<b>-P</b> Path to fIcy", "value": "" }, ] }, "youtube-dl": { "title": "youtuble-dl", "priority": "required", "type": "app", "category": "download", "version": "2017.02.11.3", "description": "Youtube downloader", "config": [ { "name": "freeformats", "arg": "--prefer-free-formats", "type": "bool", "description": "Prefer free audio formats", "value": False }, { "name": "format", "arg": "-f", "type": "select", "select": "=any|b=best|249=webm audio only DASH|250=webm audio only DASH|140=m4a audio only DASH|171=webm audio only DASH|251=webm audio only DASH|278=webm 256x144 DASH|160=mp4 256x144 DASH|242=webm 426x240 DASH|133=mp4 426x240 DASH|243=webm 640x360 DASH|134=mp4 640x360 DASH|244=webm 854x480 DASH|135=mp4 854x480 DASH|247=webm 1280x720 DASH|136=mp4 1280x720 DASH|248=webm 1920x1080 DASH|137=mp4 1920x1080 DASH|17=3gp 176x144 small|36=3gp 320x180 small|43=webm 640x360 medium|18=mp4 640x360 medium|22=mp4 1280x720 hd720", "description": "<b>-f</b> Format", "value": "b" }, { "name": "c", "arg": "-c", "type": "bool", "description": "<b>-c</b> Continue partial downloads ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ", "value": True }, { "name": "netrc", "arg": "-n", "type": "bool", "description": "<b>-n</b> Use .netrc for auth/login", "value": False }, { "name": "ignore", "arg": "-i", "type": "bool", "description": "<b>-i</b> Ignore errors", "value": False }, { "name": "proxy", "arg": "--proxy", "type": "str", "description": "<b>-p</b> Proxy", "value": "" }, { "name": "verbose", "arg": "-v", "type": "bool", "description": "<b>-v</b> Verbose mode", "value": False, "category": "extra" }, { "name": "ipv4", "arg": "-4", "type": "bool", "description": "<b>-4</b> Use IPv4", "value": False, "category": "extra" }, { "name": "ipv6", "arg": "-6", "type": "bool", "description": "<b>-6</b> Use IPv6", "value": False, "category": "extra" }, ] }, "wget": { "title": "wget", "priority": "required", "type": "app", "category": "download", "version": "1.15", "description": "HTTP download utility", "config": [ { "name": "c", "arg": "-c", "type": "bool", "description": "<b>-c</b> Continue partial downloads.", "value": True }, { "name":"nc", "arg":"-nc", "type": "bool", "description": "<b>-nc</b> No-clobber, keep existing files.", "value": False }, { "name": "N", "arg": "-N", "type": "bool", "description": "<b>-N</b> Only fetch newer files", "value": False }, { "name": "O", "arg": "-O", "type": "str", "description": "<b>-O</b> Output to file", "value": "" }, { "name": "v", "arg": "-v", "type": "bool", "description": "<b>-v</b> Verbose mode", "value": False }, { "name": "S", "arg": "-S", "type": "bool", "description": "<b>-S</b> Show response headers", "value": False }, { "name": "U", "arg": "-U", "type": "str", "description": "<b>-U</b> Useragent to send", "value": "" }, ] }, } # current selection (dialog only runs once anyway, so we can keep flags in same object) app = "streamripper" argmap = {} # "--xs2" => "xs2" |
︙ | ︙ | |||
158 159 160 161 162 163 164 | def init2(self, parent, *k, **kw): # TEMPORARY WORKAROUND: swap action.record() action.record = self.action_record # BETTER APPROACH: hook record button #parent.on_record_clicked = self.show_window # add menu entry (for simple triv#1 option) | | | | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | def init2(self, parent, *k, **kw): # TEMPORARY WORKAROUND: swap action.record() action.record = self.action_record # BETTER APPROACH: hook record button #parent.on_record_clicked = self.show_window # add menu entry (for simple triv#1 option) uikit.add_menu([parent.extensions_context], "Set single MP3 record -A flag", self.set_cont) # default widget actions parent.win_recordoptions.connect("delete-event", self.hide) parent.recordoptions_go.connect("clicked", self.do_record) parent.recordoptions_save.connect("clicked", self.save_only) parent.recordoptions_eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color("#442211")) # shortcuts self.add_plg = parent.configwin.add_plg # create _cfg widgets self.load_config = parent.configwin.load_config # populate _cfg widgets self.save_config = parent.configwin.save_config # save from _cfg widgets self.recordoptions_cfg = parent.recordoptions_cfg # our vbox widget # prepares a few shortcuts def map_app_args(self, app): config = self.flag_meta[app]["config"] self.argmap = { row["arg"].split(" ")[0]: row["name"] for row in config if row.get("arg") } self.namemap = dict(zip(self.argmap.values(), self.argmap.keys())) self.typemap = { row["name"]: row["type"] for row in config if row.get("type") } self.defmap = { row["name"]: row["value"] for row in config if row.get("value") is not None } log.CONF(self.defmap) # triv #1 menu option โ only saves `-A` flag to row["recordflags"] |
︙ | ︙ | |||
245 246 247 248 249 250 251 | p.recordoptions_title.set_text(row["title"][0:50]) p.recordoptions_url.set_text(row["url"][0:50]) # add option widgets self.load_config_widgets(row, self.app, p) # show window p.win_recordoptions.show() | < < < < | > > > > > > > > > > > > > | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | p.recordoptions_title.set_text(row["title"][0:50]) p.recordoptions_url.set_text(row["url"][0:50]) # add option widgets self.load_config_widgets(row, self.app, p) # show window p.win_recordoptions.show() # populate config widgets, seth defaults/current settings def load_config_widgets(self, row, group="streamripper", p=None): # clean up previous [self.recordoptions_cfg.remove(w) for w in self.recordoptions_cfg.get_children()] # add plugins self.add_plg(group, self.filter_options(self.flag_meta[group]), self.add_flag, self.cfg_widget_pfx) # set values self.load_config(self.configdict_from_args(row), self.cfg_widget_pfx, widgets=self.widgets) # clean up options according to each {category:} and `recordflags_extra` def filter_options(self, meta): meta = copy.copy(meta) filter = ["basic", conf.recordflags_extra, None, {"verbose":["extra"]}.get(conf.recordflags_extra)] meta["config"] = [desc for desc in meta["config"] if desc.get("category") in filter] return meta # Put config widgets into recordoptions_cfg vbox def add_flag(self, id=None, w=None, label=None, color=None, image=None, align=5): self.parent.recordoptions_cfg.pack_start(uikit.wrap(self.widgets, id, w, label, color, image, align, label_markup=1, label_size=250)) # return "--args str" for current config widget states def args_from_configwin(self): cfg = { name: None for name in self.namemap.keys() } self.save_config(cfg, self.cfg_widget_pfx, widgets=self.widgets) log.DATA(cfg) return self.args_from_configdict(cfg) #-- parse existing `record_flags` and conf.record defauls into name-config def configdict_from_args(self, row): r = copy.copy(self.defmap) # saved `record_flags` cmdstr = row.get(conf.recordflags_row, "") # add default options from configured recoding app if conf.record.get("audio/*"): add = re.findall('"(.+?)"', conf.record["audio/*"]) if add: cmdstr = add[0] + " " + cmdstr # global/default plugin option, if set if conf.recordflags_dir: r["dir"] = conf.recordflags_dir # extract for arg,val in re.findall("""(-\w+|--[\w-]+)\s*("[^"]+"|'[^']+'|[^-]+)?""", cmdstr): if not arg in self.argmap: |
︙ | ︙ |