Check-in [801ad7fd98]
Overview
Comment: | Sync with trunk changes. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | action-mapfmts |
Files: | files | file ages | folders |
SHA1: |
801ad7fd98eeee0105d79dbf305b40cb |
User & Date: | mario on 2015-04-10 10:54:35 |
Other Links: | branch diff | manifest | tags |
Context
2015-04-10
| ||
11:55 | SurfMusik actually holds .m3u playlists. check-in: 46062ce00f user: mario tags: action-mapfmts | |
10:54 | Sync with trunk changes. check-in: 801ad7fd98 user: mario tags: action-mapfmts | |
10:51 | Fix parent window references. check-in: a61a746c31 user: mario tags: trunk | |
10:45 | Update comment on rewritten action module. Add alternative MIME types for m3u and asx, spport asf detection and extraction. Fix listformat→source arg. Move save() and filename handling out of save_playlist. Fix mediafmt_t lookup and print warning when there's an audio-response on playlist fetching (and it does happen). Change myoggradio plugin "format" population, and set listformat to "mixed(..)" for automatic probing. check-in: 223368ebbf user: mario tags: action-mapfmts | |
Changes
Modified PACKAGING from [bdfee53a8f] to [1814db3da6].
1 2 3 | # pack: PACKAGING= This is a short summary for distribution package maintainers. | | > | 1 2 3 4 5 6 7 8 9 10 11 12 | # pack: PACKAGING= This is a short summary for distribution package maintainers. For regular end-user documentation please see the README and help/ pages. Structural changes from 2.1.5 onwards (2015-04-xx) -------------------------------------------------- → There's a new `bin` script. It's a lightweight invocation wrapper, intended to be installed as /usr/bin/streamtuner2 |
︙ | ︙ | |||
40 41 42 43 44 45 46 | --------- → Help files still need to go to share/docs/streamtuner2/help/ unless you patch the source. → *.desktop as usual | | | | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 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 | --------- → Help files still need to go to share/docs/streamtuner2/help/ unless you patch the source. → *.desktop as usual → and `icon.png` is the /share/pixmaps/ icon Removed ------- Most plugin PNGs may have been removed already. (Embedded binary data may violate some distro guidelines(?), but hey, fewer files are fewer files!) And the streamtuner2.png logo is now source-embedded instead; the `logo.py` module provides a `logo.png` base64-string. The old `gtk2.xml` file is gone. It probably became obsolete a long while back. The gtk3.xml is instead runtime-patched to work with PyGTK/gtk2. Dependencies ------------ If possible, make ST2 dependend on Python2 -or- Python3. It's not yet practical, and probably against distro standards, and only APT could so anyway. But if feasible... Also, hard dependencies are meanwhile: - gtk (>= 2.16) - pygtk [or python-gi for python3] - python-requests (>= 2.0.0) - python-pyquery [though most plugins would work without] - and its implied python-lxml Optional dependencies (just affects a single plugin, which semi-gracefully disables itself): - python-keybinder [for global_key] |
︙ | ︙ | |||
113 114 115 116 117 118 119 | FPM/XPM packaging ----------------- You may have noticed (and scoffed at ;) the newer packaging method. It's now using http://fossil.include-once.org/xpm/ | | | 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | FPM/XPM packaging ----------------- You may have noticed (and scoffed at ;) the newer packaging method. It's now using http://fossil.include-once.org/xpm/ with the `-s src` filter. (That's what the meta comment blocks in the source modules were always meant for.) Simplifies DEB and RPM packaging, as well as PYZ generation. (They're all workable, but decidedly rather crude packages. So yes, proper distro packages are very much still needed.) |
︙ | ︙ |
Modified channels/__init__.py from [f28fdd4cc1] to [b6c3442f9b].
︙ | ︙ | |||
102 103 104 105 106 107 108 109 110 111 112 113 114 115 | # for empty grouping / categories placeholder = [dict(genre="./.", title="Subcategory placeholder", playing="./.", url="none:", listeners=0, bitrate=0, homepage="", state="gtk-folder")] empty_stub = [dict(genre="./.", title="No categories found (HTTP error)", playing="Try Channel→Reload Categories later..", url="none:", listeners=0, bitrate=0, homepage="", state="gtk-stop")] # regex rx_www_url = re.compile("""(www(\.\w+[\w-]+){2,}|(\w+[\w-]+[ ]?\.)+(com|FM|net|org|de|PL|fr|uk))""", re.I) # constructor def __init__(self, parent=None): #self.streams = {} self.gtk_list = None self.gtk_cat = None | > > > > | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | # for empty grouping / categories placeholder = [dict(genre="./.", title="Subcategory placeholder", playing="./.", url="none:", listeners=0, bitrate=0, homepage="", state="gtk-folder")] empty_stub = [dict(genre="./.", title="No categories found (HTTP error)", playing="Try Channel→Reload Categories later..", url="none:", listeners=0, bitrate=0, homepage="", state="gtk-stop")] # regex rx_www_url = re.compile("""(www(\.\w+[\w-]+){2,}|(\w+[\w-]+[ ]?\.)+(com|FM|net|org|de|PL|fr|uk))""", re.I) #--------------------------- initialization -------------------------------- # constructor def __init__(self, parent=None): #self.streams = {} self.gtk_list = None self.gtk_cat = None |
︙ | ︙ | |||
125 126 127 128 129 130 131 | self.parent = stub_parent(None) # only if streamtuner2 is run in graphical mode if (parent): self.cache() self.gui(parent) pass | < < < < < < < < < < < < < < < < < < < < < < < < < < | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | self.parent = stub_parent(None) # only if streamtuner2 is run in graphical mode if (parent): self.cache() self.gui(parent) pass # initialize Gtk widgets / data objects def gui(self, parent): #print(self.module + ".gui()") # save reference to main window/glade API |
︙ | ︙ | |||
185 186 187 188 189 190 191 192 193 194 195 196 197 198 | self.load(self.current) else: uikit.columns(self.gtk_list, self.datamap, []) # add to main menu uikit.add_menu([parent.channelmenuitems], self.meta["title"], lambda w: parent.channel_switch_by_name(self.module) or 1) # make private copy of .datamap and modify field (title= only ATM) def update_datamap(self, search="name", title=None): if self.datamap == GenericChannel.datamap: self.datamap = copy.deepcopy(self.datamap) for i,row in enumerate(self.datamap): if row[2][0] == search: | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | self.load(self.current) else: uikit.columns(self.gtk_list, self.datamap, []) # add to main menu uikit.add_menu([parent.channelmenuitems], self.meta["title"], lambda w: parent.channel_switch_by_name(self.module) or 1) # Statusbar stub (defers to parent/main window, if in GUI mode) def status(self, *v): if self.parent: self.parent.status(*v) else: __print__(dbg.INFO, "status():", *v) #--------------------- streams/model data accesss --------------------------- # Get list of stations in current category def stations(self): return self.streams.get(self.current, []) # Convert ListStore iter to row number def rowno(self): (model, iter) = self.model_iter() return model.get_path(iter)[0] # Return ListStore object and Iterator for currently selected row in gtk.TreeView station list def model_iter(self): return self.gtk_list.get_selection().get_selected() # Currently selected entry in stations list, return complete data dict def row(self): return self.stations() [self.rowno()] # Fetches a single varname from currently selected station entry def selected(self, name="url"): return self.row().get(name) # Inject status icon into currently selected row (used by main.bookmark() call) def row_icon(self, gtkIcon = gtk.STOCK_ABOUT): try: # Updates gtk_list store, set icon in current display. # Since it is used by bookmarks, would be reshown with next display() anyhow, # and there's no need to invalidate the ls cache, because that's referenced by model anyhow. (model,iter) = self.model_iter() model.set_value(iter, 0, gtkIcon) except: pass #------------------------ base implementations ----------------------------- # read previous channel/stream data, if there is any def cache(self): # stream list cache = conf.load("cache/" + self.module) if (cache): self.streams = cache # categories cache = conf.load("cache/categories_" + self.module) if (cache): self.categories = cache # catmap (optional) cache = conf.load("cache/catmap_" + self.module) if (cache): self.catmap = cache pass # make private copy of .datamap and modify field (title= only ATM) def update_datamap(self, search="name", title=None): if self.datamap == GenericChannel.datamap: self.datamap = copy.deepcopy(self.datamap) for i,row in enumerate(self.datamap): if row[2][0] == search: |
︙ | ︙ | |||
439 440 441 442 443 444 445 | return self.current #--------------------------- actions --------------------------------- | | | | > | | < < | > > > > > > > > > > > | 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | return self.current #--------------------------- actions --------------------------------- # Invoke action.play() for current station. # Can be overridden to provide channel-specific "play" alternative def play(self): row = self.row() if row: # playlist and audio type audioformat = row.get("format", self.audioformat) listformat = row.get("listformat", self.listformat) # invoke audio player action.play(row["url"], audioformat, listformat, row) else: self.status("No station selected for playing.") return row # Start streamripper/youtube-dl/etc def record(self): row = self.row() if row: audioformat = row.get("format", self.audioformat) listformat = row.get("listformat", self.listformat) action.record(row.get("url"), audioformat, listformat, row=row) return row #--------------------------- utility functions ----------------------- |
︙ | ︙ |
Modified channels/bookmarks.py from [7e6a019f1a] to [c19e57d351].
︙ | ︙ | |||
28 29 30 31 32 33 34 | # layout. Which is why it derives from GenericChannel, and requires # less setup. # # Furthermore it pretty much only handles a static streams{} list. # Sub-plugins simply append a new category, and populate the streams # list themselves. # | | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # layout. Which is why it derives from GenericChannel, and requires # less setup. # # Furthermore it pretty much only handles a static streams{} list. # Sub-plugins simply append a new category, and populate the streams # list themselves. # # It's accessible as `parent.bookmarks` in the ST2 window and elsewhere. # class bookmarks(GenericChannel): # desc module = "bookmarks" title = "bookmarks" base_url = "file:.config/streamtuner2/bookmarks.json" |
︙ | ︙ | |||
105 106 107 108 109 110 111 | def add(self, row): # normalize data (this row originated in a gtk+ widget) row["favourite"] = 1 if row.get("favicon"): row["favicon"] = favicon.file(row.get("homepage")) if not row.get("listformat"): | | | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | def add(self, row): # normalize data (this row originated in a gtk+ widget) row["favourite"] = 1 if row.get("favicon"): row["favicon"] = favicon.file(row.get("homepage")) if not row.get("listformat"): row["listformat"] = self.parent.channel().listformat # append to storage self.streams["favourite"].append(row) self.save() self.load(self.default) self.urls.append(row["url"]) |
︙ | ︙ | |||
154 155 156 157 158 159 160 | # First we'll generate a list of current bookmark stream urls, and then # remove all but those from the currently UPDATED_channel + category. # This step is most likely redundant, but prevents accidently re-rewriting # stations that are in two channels (=duplicates with different PLS urls). check = {"http//": "[row]"} check = dict((row.get("url", "http//"),row) for row in fav) # walk through all channels/streams | | | 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | # First we'll generate a list of current bookmark stream urls, and then # remove all but those from the currently UPDATED_channel + category. # This step is most likely redundant, but prevents accidently re-rewriting # stations that are in two channels (=duplicates with different PLS urls). check = {"http//": "[row]"} check = dict((row.get("url", "http//"),row) for row in fav) # walk through all channels/streams for chname,channel in self.parent.channels.items(): for cat,streams in channel.streams.items(): # keep the potentially changed rows if (chname == updated_channel) and (cat == updated_category): freshened_streams = streams # remove unchanged urls/rows |
︙ | ︙ |
Modified channels/exportcat.py from [b38cb32770] to [1a24ff64fc].
︙ | ︙ | |||
42 43 44 45 46 47 48 | uikit.add_menu([parent.extensions, parent.extensions_context], "Export all stations", self.savewindow) # Fetch streams from category, show "Save as" dialog, then convert URLs and export as playlist file def savewindow(self, *w): cn = self.parent.channel() source = cn.listformat streams = cn.streams[cn.current] | | | < | 42 43 44 45 46 47 48 49 50 51 52 53 54 | uikit.add_menu([parent.extensions, parent.extensions_context], "Export all stations", self.savewindow) # Fetch streams from category, show "Save as" dialog, then convert URLs and export as playlist file def savewindow(self, *w): cn = self.parent.channel() source = cn.listformat streams = cn.streams[cn.current] fn = uikit.save_file("Export category", None, "%s.%s.%s" % (cn.module, cn.current, conf.export_format)) __print__(dbg.PROC, "Exporting category to", fn) if fn: dest = re.findall("\.(m3u|pls|xspf|jspf|json|smil|wpl)8?$", fn)[0] action.save_playlist(source="asis", multiply=False).file(rows=streams, fn=fn, dest=dest) pass |
Modified st2.py from [707c0d6df4] to [c18d3ab85b].
︙ | ︙ | |||
66 67 68 69 70 71 72 | # This represents the main window, dispatches Gtk events, # and shares most application behaviour with the channel modules. class StreamTunerTwo(gtk.Builder): # object containers | | > | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | # This represents the main window, dispatches Gtk events, # and shares most application behaviour with the channel modules. class StreamTunerTwo(gtk.Builder): # object containers widgets = {} # non-glade widgets (any manually instantiated ones) channels = {} # channel modules features = {} # non-channel plugins working = [] # threads hooks = { "play": [favicon.download_playing], # observers queue here "record": [], "init": [], "config_load": [], "config_save": [], } meta = plugin_meta() |
︙ | ︙ | |||
258 259 260 261 262 263 264 | self.notebook_channels.set_current_page(self.channel_names.index(name)) # Mirror selected channel tab into main window title def update_title(self): self.win_streamtuner2.set_title("Streamtuner2 - %s" % self.channel().meta.get("title")) | < < < < | < | | < < < < < | > | < | | > | < > | 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 | self.notebook_channels.set_current_page(self.channel_names.index(name)) # Mirror selected channel tab into main window title def update_title(self): self.win_streamtuner2.set_title("Streamtuner2 - %s" % self.channel().meta.get("title")) # Channel: row{} dict for current station def row(self): return self.channel().row() # Channel: fetch single varname from station row{} dict def selected(self, name="url"): return self.row().get(name) # Play button def on_play_clicked(self, widget, event=None, *args): self.status("Starting player...") row = self.channel().play() self.status("") [callback(row) for callback in self.hooks["play"]] # Recording: invoke streamripper for current stream URL def on_record_clicked(self, widget): self.status("Recording station...") row = self.channel().record() [callback(row) for callback in self.hooks["record"]] # Open stream homepage in web browser def on_homepage_stream_clicked(self, widget): url = self.selected("homepage") if url and len(url): action.browser(url) else: self.status("No homepage URL present.") |
︙ | ︙ | |||
329 330 331 332 333 334 335 | __print__(dbg.UI, "on_category_clicked", category, self.current_channel) self.on_reload_clicked(None, reload=0) pass # Add current selection to bookmark store def bookmark(self, widget): self.bookmarks.add(self.row()) | < < < | < < | | > | | | | 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | __print__(dbg.UI, "on_category_clicked", category, self.current_channel) self.on_reload_clicked(None, reload=0) pass # Add current selection to bookmark store def bookmark(self, widget): self.bookmarks.add(self.row()) self.channel().row_icon(gtk.STOCK_ABOUT) # refresh bookmarks tab self.bookmarks.load(self.bookmarks.default) # Reload category tree def update_categories(self, widget): Thread(target=self.channel().reload_categories).start() # Menu invocation: refresh favicons for all stations in current streams category def update_favicons(self, widget): entries = self.channel().stations() favicon.download_all(entries) # Save stream to file (.m3u) def save_as(self, widget): row = self.row() default_fn = row["title"] + ".m3u" fn = uikit.save_file("Save Stream", None, default_fn, [(".m3u","*m3u"),(".pls","*pls"),(".xspf","*xspf"),(".jspf","*jspf"),(".smil","*smil"),(".asx","*asx"),("all files","*")]) if fn: source = row.get("listformat", self.channel().listformat) dest = (re.findall("\.(m3u|pls|xspf|jspf|json|smil|asx|wpl)8?$", fn) or ["pls"])[0] action.save_playlist(source=source, multiply=True).save(rows=[row], fn=fn, dest=dest) pass # Save current stream URL into clipboard def menu_copy(self, w): gtk.clipboard_get().set_text(self.selected("url")) # Remove a stream entry def delete_entry(self, w): cn = self.channel() n = cn.rowno() del cn.stations()[ n ] cn.switch() cn.save() # Alternative Notebook channel tabs between TOP and LEFT position def switch_notebook_tabs_position(self, w, pos): self.notebook_channels.set_tab_pos(pos); |
︙ | ︙ |