Index: action.py
==================================================================
--- action.py
+++ action.py
@@ -2,19 +2,22 @@
# encoding: UTF-8
# api: streamtuner2
# type: functions
# title: play/record actions
# description: Starts audio applications, guesses MIME types for URLs
+# version: 0.7
#
#
-# Multimedia interface for starting audio players or browser.
+# Multimedia interface for starting audio players, recording app,
+# or web browser (listed as "url/http" association in players).
#
#
# Each channel plugin has a .listtype which describes the linked
# audio playlist format. It's audio/x-scpls mostly, seldomly m3u,
# but sometimes url/direct if the entry[url] directly leads to the
# streaming server.
+#
# As fallback there is a regex which just looks for URLs in the
# given resource (works for m3u/pls/xspf/asx/...). There is no
# actual url "filename" extension guessing.
#
#
@@ -65,16 +68,15 @@
# 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 )
+ if audioformat == "audio/mp3":
+ audioformat = "audio/mpeg"
+ cmd = action.mime_match(audioformat, conf.play)
try:
+ __print__( dbg.PROC, "play", url, cmd )
action.run( action.interpol(cmd, url) )
except:
pass
@@ -89,14 +91,22 @@
# 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.play.get("record", None))
+ cmd = action.mime_match(audioformat, conf.record)
try: action.run( action.interpol(cmd, url, row) + append )
except: pass
+
+ # Convert MIME type into list of ["audio/xyz", "audio/*", "*/*"] for comparison against record/play association
+ @staticmethod
+ def mime_match(fmt, cmd_list):
+ for match in [ fmt, fmt[:fmt.find("/")] + "/*", "*/*" ]:
+ if cmd_list.get(match, None):
+ return cmd_list[match]
+
# save as .m3u
@staticmethod
def save(row, fn, listformat="audio/x-scpls"):
# modify stream url
Index: config.py
==================================================================
--- config.py
+++ config.py
@@ -65,15 +65,15 @@
self.play = {
"audio/mpeg": "audacious ", # %u for url to .pls, %g for downloaded .m3u
"audio/ogg": "audacious ",
"audio/*": "totem ",
"video/*": "vlc --one-instance %srv",
- "record": "x-terminal-emulator -e streamripper %srv",
- # x-terminal-emulator -e streamripper %srv -d /home/***USERNAME***/Musik
"url/http": "sensible-browser",
}
self.record = {
+ "audio/*": "xterm -e streamripper %srv", # -d /home/***USERNAME***/Musik
+ "video/youtube": "xterm -e youtube-dl %srv",
}
self.plugins = {
"bookmarks": 1, # built-in plugins, cannot be disabled
"shoutcast": 1,
"xiph": 1,
Index: gtk2.xml
==================================================================
--- gtk2.xml
+++ gtk2.xml
@@ -9,10 +9,20 @@
+
+
True
True
+ 5
2
+
+
+ True
+ False
+ 0
+ True
+
+
+ True
+ True
+ 3
+
+
+
+
+ True
+ False
+ 0
+ <b>Recording</b> applications.
+ True
+
+
+ True
+ True
+ 4
+
+
+
+
+ True
+ True
+ automatic
+ automatic
+
+
+ 0
+ 100
+ True
+ True
+ 5
+ config_record
+ False
+ True
+ 0
+ 8
+ both
+
+
+ 10
+ 125
+ Format
+ True
+
+
+
+
+
+ 2
+ 0
+
+
+
+
+
+
+ 10
+ 300
+ Application
+
+
+
+
+
+ 2
+ 1
+
+
+
+
+
+
+
+
+ True
+ True
+ 5
+
+
+
+
+ True
+ True
+ 0.019999999552965164
+ 0.49000000953674316
+ You usually want to run recording applications in a
+terminal window, as they're commandline tools.
+ True
+ True
+
+
+ True
+ True
+ 15
+ 6
+
+
+
+
+
+
+
+
@@ -1643,10 +1766,100 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
all channels
True
True
@@ -2273,10 +2486,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
True
True
●
@@ -2291,10 +2540,16 @@
2
1
2
+
+
+
+
+
+
Index: gtk3.xml
==================================================================
--- gtk3.xml
+++ gtk3.xml
@@ -9,10 +9,20 @@
+
+
+
+
+
+
+
+
+
+
565
False
streamtuner settings
@@ -54,11 +64,11 @@
True
False
0
- <b>Audio player</b> and <b>recording</b> applications.
+ <b>Audio player</b> association.
True
True
True
@@ -140,13 +150,127 @@
True
True
True
+ 5
2
+
+
+ True
+ False
+ 0
+ True
+
+
+ True
+ True
+ 3
+
+
+
+
+ True
+ False
+ 0
+ <b>Recording</b> applications.
+ True
+
+
+ True
+ True
+ 4
+
+
+
+
+ True
+ True
+
+
+ 0
+ 100
+ True
+ True
+ 5
+ config_record
+ False
+ True
+ 0
+ 8
+ both
+
+
+
+
+
+ 10
+ 125
+ Format
+ True
+
+
+
+
+
+ 2
+ 0
+
+
+
+
+
+
+ 10
+ 300
+ Application
+
+
+
+
+
+ 2
+ 1
+
+
+
+
+
+
+
+
+ True
+ True
+ 5
+
+
+
+
+ True
+ True
+ 0.019999999552965164
+ 0.49000000953674316
+ You usually want to run recording applications in a
+terminal window, as they're commandline tools.
+ True
+ True
+
+
+ True
+ True
+ 15
+ 6
+
+
+
+
+
+
+
+
@@ -1674,10 +1798,100 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
all channels
True
True
@@ -2327,10 +2541,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
True
True
●
@@ -2343,10 +2593,16 @@
2
1
2
+
+
+
+
+
+
@@ -3349,11 +3605,11 @@
True
True
True
-
+
@@ -3371,11 +3627,11 @@
True
True
-
+
Index: st2.py
==================================================================
--- st2.py
+++ st2.py
@@ -188,10 +188,12 @@
"menu_properties": config_dialog.open,
"config_cancel": config_dialog.hide,
"config_save": config_dialog.save,
"config_player_edited": config_dialog.edited_player_row,
"config_player_edited_2": config_dialog.edited_player_row_2,
+ "config_record_edited": config_dialog.edited_record_row,
+ "config_record_edited_2": config_dialog.edited_record_row_2,
"update_categories": self.update_categories,
"update_favicons": self.update_favicons,
"app_state": self.app_state,
"bookmark": self.bookmark,
"save_as": self.save_as,
@@ -799,10 +801,14 @@
# Gtk callback to update ListStore when entries get edited
def edited_player_row(self, cell, path, new_text, user_data=None, column=0):
main.config_play[path][column] = new_text
def edited_player_row_2(self, cell, path, new_text, user_data=None):
self.edited_player_row(cell, path, new_text, column=1)
+ def edited_record_row(self, cell, path, new_text, user_data=None, column=0):
+ main.config_record[path][column] = new_text
+ def edited_record_row_2(self, cell, path, new_text, user_data=None):
+ self.edited_record_row(cell, path, new_text, column=1)
# list of Gtk themes in dropdown
def combobox_theme(self):
# find themes