Index: channels/exportcat.py ================================================================== --- channels/exportcat.py +++ channels/exportcat.py @@ -1,25 +1,29 @@ # encoding: UTF-8 # api: streamtuner2 -# title: Export All +# title: Export Category # description: Exports a complete channel category (all stations into one file). -# version: -0.1 +# version: 0.2 # type: feature # category: file # priority: optional # config: -# { name: export_format, value: pls, type: select, select: "pls|xspf|m3u|jspf|smil|asx|json", description: Export format. } +# { name: export_format, value: xspf, type: select, select: "pls|xspf|m3u|jspf|smil|asx|json", description: Default export format. } # hooks: config_save # -# Use "Extensions > Export all" in the desired channel and category, -# to export all station entries at once. Currently just export PLS, -# which in turn references other .pls file). Luckily most players -# can cover up for this horrid misdesign. +# Adds a context menu "Extensions > Export all", which can be used +# in any channel and category to save all stations into one playlist. +# Defaults to exporting as .PLS file, but meanwhile can be used for +# XSPF or old M3U files as well. +# Note that a .desktop link can only hold the very first entry. +# +# It won't convert the internal stream URLs though. Such that the +# combined playlist file may reference further playlists from servers +# of a directory provider. # # This is a workaround until the main GUI supports selecting multiple -# rows at once, and the action.* module has been overhauled to export -# a bit more deterministically. +# rows at once. You can already save as from config import * from channels import * import ahttp @@ -47,13 +51,13 @@ 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)) log.PROC("Exporting category to", fn) if fn: - dest = re.findall("\.(m3u8?|pls|xspf|jspf|json|smil|asx)8?$", fn.lower()) + dest = re.findall("\.(m3u|pls|xspf|jspf|json|smil|asx|desktop|url)8?$", fn.lower()) if dest: dest = dest[0] else: self.parent.status("Unsupported export playlist type (file extension).") return action.save_playlist(source="asis", multiply=False).file(rows=streams, fn=fn, dest=dest) pass Index: uikit.py ================================================================== --- uikit.py +++ uikit.py @@ -359,11 +359,11 @@ #-- Save-As dialog # @staticmethod - def save_file(title="Save As", parent=None, fn="", formats=[("*.pls", "*.pls"), ("*.xspf", "*.xpsf"), ("*.m3u", "*.m3u"), ("*.jspf", "*.jspf"), ("*.asx", "*.asx"), ("*.json", "*.json"), ("*.smil", "*.smil"), ("*.wpl", "*.wpl"), ("*","*")]): + def save_file(title="Save As", parent=None, fn="", formats=[("*.pls", "*.pls"), ("*.xspf", "*.xpsf"), ("*.m3u", "*.m3u"), ("*.jspf", "*.jspf"), ("*.asx", "*.asx"), ("*.json", "*.json"), ("*.smil", "*.smil"), ("*.desktop", "*.desktop"), ("*","*")]): # With overwrite confirmation c = gtk.FileChooserDialog(title, parent, action=gtk.FILE_CHOOSER_ACTION_SAVE, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK)) c.set_do_overwrite_confirmation(True) @@ -395,11 +395,11 @@ @staticmethod def save_file_filterchange(c): fn, ext = c.get_filename(), c.get_filter().get_name() if fn and ext: fn = os.path.basename(fn) - c.set_current_name(re.sub(r"\.(m3u|pls|xspf|jspf|asx|json|smil|wpl)$", ext.strip("*"), fn)) + c.set_current_name(re.sub(r"\.(m3u|pls|xspf|jspf|asx|json|smil|desktop|url|wpl)8?$", ext.strip("*"), fn)) # Spool gtk update calls from non-main threads (optional immediate=1 flag to run task next, not last) @staticmethod