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

⌈⌋ ⎇ branch:  streamtuner2


Diff

Differences From Artifact [005725eacf]:

To Artifact [0cb40c6df9]:

  • File action.py — part of check-in [23bbd97989] at 2015-05-24 14:19:06 on branch trunk — Introduce action.handler{} callbacks to convert custom streaming URL types such as "audio/soundcloud". Unify backend code for .play/record/browser() calls. Reddit module just splits out domain name now, then checks for walledgarden links (filter option renamed). Introduce url_soundcloud plugin in favour of `soundcli` cmdline client setting. (user: mario, size: 25573) [annotate] [blame] [check-ins using]

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
152
153



154
155


156

157
158
159
160
161
162
163
164
165
166
167
]

# Preferred probing order of known formats
playlist_fmt_prio = [
   "pls", "xspf", "asx", "smil", "jamj", "json", "m3u", "asf", "raw"
]








# 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)


# Start web browser
#
def browser(url):
    bin = conf.play.get("url/http", "sensible-browser")
    log.EXEC(bin)
    run(bin + " " + quote(url))


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


# Calls player for stream url and format
#
def play(row={}, audioformat="audio/mpeg", source="pls", url=None):





    cmd = mime_app(audioformat, conf.play)
    cmd = interpol(cmd, url or row["url"], source, row)
    run(cmd)





# Call streamripper


#

def record(row={}, audioformat="audio/mpeg", source="href", url=None):
    cmd = mime_app(audioformat, conf.record)
    cmd = interpol(cmd, url or row["url"], source, row)
    run(cmd)


# OS shell command escaping
#
def quote(ins):
    if type(ins) is list:
        return " ".join(["%r" % str(s) for s in ins])







>
>
>
>
>



<





<
<
<
<
<
<
<
<
<

<



<
|
<
|
>
>
>
>
>
|
|
|

>
>
>

|
>
>
|
>

|
<
<







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
152
153
154
155
156
157
158
159
160
161


162
163
164
165
166
167
168
]

# Preferred probing order of known formats
playlist_fmt_prio = [
   "pls", "xspf", "asx", "smil", "jamj", "json", "m3u", "asf", "raw"
]

# custom stream domain handlers
handler = {
    # "soundcloud": callback(),
}



# 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", url=None, assoc={}):
    if not url:
        url = row["url"]
    if audioformat in handler:
        handler[audioformat](row, audioformat, source, url, assoc)
    else:
        cmd = mime_app(audioformat, assoc)
        cmd = interpol(cmd, url, source, row)
        run(cmd)

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

# Calls player for stream url and format
def play(row={}, audioformat="audio/mpeg", source="pls", url=None):
    run_fmt_url(row, audioformat, source, url, conf.play)

# Call streamripper / youtube-dl / wget
def record(row={}, audioformat="audio/mpeg", source="href", url=None):
    run_fmt_url(row, audioformat, source, url, conf.record)




# OS shell command escaping
#
def quote(ins):
    if type(ins) is list:
        return " ".join(["%r" % str(s) for s in ins])