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
85
86
87
88
89
90 | #
class action:
# streamlink formats
lt = {"asx":"video/x-ms-asf", "pls":"audio/x-scpls", "m3u":"audio/x-mpegurl", "xspf":"application/xspf+xml", "href":"url/http", "ram":"audio/x-pn-realaudio", "smil":"application/smil"}
# media formats
mf = {"mp3":"audio/mp3", "ogg":"audio/ogg", "aac":"audio/aac"}
# web
@staticmethod
def browser(url):
__print__( conf.browser )
os.system(conf.browser + " '" + action.quote(url) + "' &")
# os shell cmd escaping
@staticmethod
def quote(s):
return "%r" % s
# calls player for stream url and format
@staticmethod
def play(url, audioformat="audio/mp3", listformat="text/x-href"):
if (url):
url = action.url(url, listformat)
if (audioformat):
if audioformat == "audio/mpeg":
audioformat = "audio/mp3" # internally we use the more user-friendly moniker
cmd = conf.play.get(audioformat, conf.play.get("*/*", "vlc %u"))
__print__( "play", url, cmd )
try:
action.run( action.interpol(cmd, url) )
except:
pass
@staticmethod
def run(cmd):
__print__( cmd )
os.system(cmd + (" &" if platform.system()!="Windows" else ""))
# streamripper
@staticmethod
def record(url, audioformat="audio/mp3", listformat="text/x-href", append="", row={}):
__print__( "record", url )
cmd = conf.record.get(audioformat, conf.record.get("*/*", None)) |
|
|
|
>
>
>
>
>
|
|
>
>
|
>
>
|
| 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99 | #
class action:
# streamlink formats
lt = {"asx":"video/x-ms-asf", "pls":"audio/x-scpls", "m3u":"audio/x-mpegurl", "xspf":"application/xspf+xml", "href":"url/http", "ram":"audio/x-pn-realaudio", "smil":"application/smil"}
# media formats
mf = {"mp3":"audio/mp3", "ogg":"audio/ogg", "aac":"audio/aac"}
# web
@staticmethod
def browser(url):
__print__( conf.browser )
action.run(conf.browser + " " + action.quote(url))
# os shell cmd escaping
@staticmethod
def quote(s):
if conf.windows:
return s # should actually be "\\\"%s\\\"" % s
else:
return "%r" % s
# calls player for stream url and format
@staticmethod
def play(url, audioformat="audio/mp3", listformat="text/x-href"):
if (url):
url = action.url(url, listformat)
if (audioformat):
if audioformat == "audio/mpeg":
audioformat = "audio/mp3" # internally we use the more user-friendly moniker
cmd = conf.play.get(audioformat, conf.play.get("*/*", "vlc %u"))
__print__( "play", url, cmd )
try:
action.run( action.interpol(cmd, url) )
except:
pass
# exec wrapper
@staticmethod
def run(cmd):
if conf.windows:
os.system("start \"%s\"")
else:
os.system(cmd + " &")
# streamripper
@staticmethod
def record(url, audioformat="audio/mp3", listformat="text/x-href", append="", row={}):
__print__( "record", url )
cmd = conf.record.get(audioformat, conf.record.get("*/*", None)) |
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234 | # use shoutcast unique stream id if available
stream_id = re.search("http://.+?/.*?(\d+)", pls, re.M)
stream_id = stream_id and stream_id.group(1) or "XXXXXX"
try:
channelname = main.current_channel
except:
channelname = "unknown"
return (conf.tmp+"/streamtuner2."+channelname+"."+stream_id+".m3u", len(stream_id) > 3 and stream_id != "XXXXXX")
# check if there are any urls in a given file
@staticmethod
def has_urls(tmp_fn):
if os.path.exists(tmp_fn):
return open(tmp_fn, "r").read().find("http://") > 0
|
|
|
| 228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243 | # use shoutcast unique stream id if available
stream_id = re.search("http://.+?/.*?(\d+)", pls, re.M)
stream_id = stream_id and stream_id.group(1) or "XXXXXX"
try:
channelname = main.current_channel
except:
channelname = "unknown"
return (conf.tmp + os.sep + "streamtuner2."+channelname+"."+stream_id+".m3u", len(stream_id) > 3 and stream_id != "XXXXXX")
# check if there are any urls in a given file
@staticmethod
def has_urls(tmp_fn):
if os.path.exists(tmp_fn):
return open(tmp_fn, "r").read().find("http://") > 0
|
260
261
262
263
264
265
266
267
268
269
270
271
272 | __print__( "error, there were no URLs in ", pls )
raise "Empty PLS"
# open help browser
@staticmethod
def help(*args):
os.system("yelp /usr/share/doc/streamtuner2/help/ &")
#or action.browser("/usr/share/doc/streamtuner2/")
#class action
|
|
| 269
270
271
272
273
274
275
276
277
278
279
280
281 | __print__( "error, there were no URLs in ", pls )
raise "Empty PLS"
# open help browser
@staticmethod
def help(*args):
action.run("yelp /usr/share/doc/streamtuner2/help/")
#or action.browser("/usr/share/doc/streamtuner2/")
#class action
|