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

⌈⌋ ⎇ branch:  streamtuner2


Diff

Differences From Artifact [f35a591c53]:

To Artifact [53a5386135]:


128
129
130
131
132
133
134





135
136

137
138
139
140
141
142
143
144

145
146
147
148
149


150

151
152
153
154
155
156
157
158
    # "urn:reciva": stream_resolve(),
}



# Exec wrapper
def run(cmd):





    log.EXEC(cmd)
    try:    os.system("start %s" % cmd if conf.windows else cmd + " &")

    except: log.ERR("Command not found:", cmd)

# Open help browser, streamtuner2 pages
def help(*args):
    run("yelp /usr/share/doc/streamtuner2/help/")

# Invokes player/recorder for stream url and format
def run_fmt_url(row={}, audioformat="audio/mpeg", source="pls", assoc={}, append=None):

    if audioformat in handler:
        handler[audioformat](row, audioformat, source, assoc)
    elif row.get("url", "").startswith("urn:"):
        row = resolve_urn(row);
    else:


        cmd = mime_app(audioformat, assoc)

        cmd = interpol(cmd, source, row)
        if append:
            cmd = re.sub('(["\']?\s*)$', " " + append + "\\1", cmd)
        run(cmd)

# Start web browser
def browser(url):
    run_fmt_url({"url": url, "homepage": url}, "url/http", "srv", conf.play)







>
>
>
>
>
|
|
>
|






|
>





>
>
|
>
|







128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
    # "urn:reciva": stream_resolve(),
}



# Exec wrapper
def run(cmd):
    if conf.windows:
        cmd = "start " + cmd
    else:
        cmd = cmd + " &"
    try:
        log.EXEC(cmd)
        os.system(cmd)
    except:
        log.ERR("Command not found:", cmd)

# Open help browser, streamtuner2 pages
def help(*args):
    run("yelp /usr/share/doc/streamtuner2/help/")

# Invokes player/recorder for stream url and format
def run_fmt_url(row={}, audioformat="audio/mpeg", source="pls", assoc={}, append=None, cmd=None, add_default=True):
    # look for specific "audio/type" or "urn:service:…" resolvers
    if audioformat in handler:
        handler[audioformat](row, audioformat, source, assoc)
    elif row.get("url", "").startswith("urn:"):
        row = resolve_urn(row);
    else:
        # use default handler for mime type
        if not cmd:
            cmd = mime_app(audioformat, assoc)
        # replace %u, %url or $title placeholders
        cmd = interpol(cmd, source, row, add_default=add_default)
        if append:
            cmd = re.sub('(["\']?\s*)$', " " + append + "\\1", cmd)
        run(cmd)

# Start web browser
def browser(url):
    run_fmt_url({"url": url, "homepage": url}, "url/http", "srv", conf.play)
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
            log.WARN("There's currently no action.handler[] for %s:#id streaming addresses (likely disabled channel plugin)." % urn_service)
    return row


# Replaces instances of %m3u, %pls, %srv in a command string
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
#  · Also understands short aliases %l, %f, %d.
#  · And can embed %title or %genre placeholders.
#  · Replace .pls URL with local .m3u file depending on map.
#
def interpol(cmd, source="pls", row={}, add_default=True):
    row = copy.copy(row)

    # Inject other meta fields (%title, %genre, %playing, %format, etc.)
    rx_keys = "[\$\%](" + "|".join(row.keys()) + ")\\b"







|







217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
            log.WARN("There's currently no action.handler[] for %s:#id streaming addresses (likely disabled channel plugin)." % urn_service)
    return row


# Replaces instances of %m3u, %pls, %srv in a command string
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
#  · Also understands short aliases %l, %f, %d.
#  · And can embed %title or $genre placeholders (may use either % or $).
#  · Replace .pls URL with local .m3u file depending on map.
#
def interpol(cmd, source="pls", row={}, add_default=True):
    row = copy.copy(row)

    # Inject other meta fields (%title, %genre, %playing, %format, etc.)
    rx_keys = "[\$\%](" + "|".join(row.keys()) + ")\\b"