Internet radio browser GUI for music/video streams from various directory services.

⌈⌋ ⎇ branch:  streamtuner2


Check-in [8b7b270591]

Overview
Comment:Temporary export mechanism (saves whole category into .pls file).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8b7b270591b701de527f95ac9b3c398f4ea8551d
User & Date: mario on 2015-04-07 05:55:24
Other Links: manifest | tags
Context
2015-04-07
19:48
Got rid of switchy() expression, use plain `cond and val or ...` chain. check-in: 30dd0c5b1f user: mario tags: trunk
05:55
Temporary export mechanism (saves whole category into .pls file). check-in: 8b7b270591 user: mario tags: trunk
05:54
Less indentation, starting to overhaul action.save() at least. (Whole `action` module is overdue.) check-in: 7726e18571 user: mario tags: trunk
Changes

Makefile became executable with contents [d3f05bad3b].

Added channels/exportcat.py version [878cc6dbbd].





























































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# encoding: UTF-8
# api: streamtuner2
# title: Export All
# description: Exports a complete channel category (all stations into one file).
# version: -0.1
# type: feature
# category: file
# priority: optional
# config:
#   { name: export_format, value: pls, type: select, select: "pls|xspf|jspf", description: 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.
#
# 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.


from config import *
from channels import *
import ahttp
from uikit import uikit

# provides another export window, and custom file generation - does not use action.save()
class exportcat():

    module = ""
    meta = plugin_meta()

    # register
    def __init__(self, parent):
        conf.add_plugin_defaults(self.meta, self.module)
        if parent:
            self.parent = parent
            uikit.add_menu([parent.extensions, parent.extensions_context], "Export all stations", self.savewindow)

    # set new browser string in requests session
    def savewindow(self, *w):
        cn = self.parent.channel()
        streams = cn.streams[cn.current]
        fn = uikit.save_file("Export category", None, "stationlist." + conf.export_format, formats=[("*.xspf", "*.xpsf"),("*.m3u", "*.m3u")])
        with open(fn, "w") as f:
            __print__(dbg.PROC, "Exporting category to", fn)
            f.write(self.pls(streams))
        return

    # plain PLS file
    def pls(self, streams):
        txt = "[playlist]\n"
        txt += "numberofentries=%s\n\n" % len(streams)
        for i,row in enumerate(streams):
            i = str(i)
            txt += "File"+i + "=" + row["url"] + "\n"
            txt += "Title"+i + "=" + row["title"] + "\n"
            txt += "Length"+i + "=-1\n\n"
        txt += "Version=2\n"
        return txt