37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 | # but also "browser" for web URLs
#
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__( dbg.CONF, conf.browser )
action.run(conf.browser + " " + action.quote(url)) |
|
| 37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 | # but also "browser" for web URLs
#
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/mpeg", "ogg":"audio/ogg", "aac":"audio/aac"}
# web
@staticmethod
def browser(url):
__print__( dbg.CONF, conf.browser )
action.run(conf.browser + " " + action.quote(url)) |
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 | return str(s) # should actually be "\\\"%s\\\"" % s
else:
return "%r" % str(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__( dbg.PROC,"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__( dbg.PROC, "record", url )
cmd = conf.record.get(audioformat, conf.record.get("*/*", None))
try: action.run( action.interpol(cmd, url, row) + append )
except: pass
# save as .m3u |
|
|
|
|
| 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 | return str(s) # should actually be "\\\"%s\\\"" % s
else:
return "%r" % str(s)
# calls player for stream url and format
@staticmethod
def play(url, audioformat="audio/mpeg", listformat="text/x-href"):
if (url):
url = action.url(url, listformat)
if (audioformat):
if audioformat == "audio/mp3":
audioformat = "audio/mpeg"
cmd = conf.play.get(audioformat, conf.play.get("*/*", "vlc %u"))
__print__( dbg.PROC,"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/mpeg", listformat="text/x-href", append="", row={}):
__print__( dbg.PROC, "record", url )
cmd = conf.record.get(audioformat, conf.record.get("*/*", None))
try: action.run( action.interpol(cmd, url, row) + append )
except: pass
# save as .m3u |
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221 | # extract stream address from .pls URL
if (re.search("\.pls", pls)): #audio/x-scpls
return action.pls(pls)
elif (re.search("\.asx", pls)): #video/x-ms-asf
return re.findall("<Ref\s+href=\"(http://.+?)\"", http.get(pls))
elif (re.search("\.m3u|\.ram|\.smil", pls)): #audio/x-mpegurl
return re.findall("(http://[^\s]+)", http.get(pls), re.I)
else: # just assume it was a direct mp3/ogg streamserver link
return [ (pls if pls.startswith("/") else http.fix_url(pls)) ]
pass
# generate filename for temporary .m3u, if possible with unique id
@staticmethod
def tmp_fn(pls): |
|
| 207
208
209
210
211
212
213
214
215
216
217
218
219
220
221 | # extract stream address from .pls URL
if (re.search("\.pls", pls)): #audio/x-scpls
return action.pls(pls)
elif (re.search("\.asx", pls)): #video/x-ms-asf
return re.findall("<Ref\s+href=\"(http://.+?)\"", http.get(pls))
elif (re.search("\.m3u|\.ram|\.smil", pls)): #audio/x-mpegurl
return re.findall("(http://[^\s]+)", http.get(pls), re.I)
else: # just assume it was a direct mpeg/ogg streamserver link
return [ (pls if pls.startswith("/") else http.fix_url(pls)) ]
pass
# generate filename for temporary .m3u, if possible with unique id
@staticmethod
def tmp_fn(pls): |