ADDED contrib/cfg_soundcloud.py Index: contrib/cfg_soundcloud.py ================================================================== --- contrib/cfg_soundcloud.py +++ contrib/cfg_soundcloud.py @@ -0,0 +1,27 @@ +# api: streamtuner2 +# title: Soundcloud player +# description: Just sets a new configuration option for `soundcli` +# version: -1 +# url: http://elephly.net/soundcli.html +# priority: once +# type: config +# category: player +# +# You only need to run this plugin once. It just adds an +# entry for "audio/soundcloud" in the player config list. + +from config import * + +# just once +class cfg_soundcloud(object): + + module = "cfg_soundcloud" + fmt = "audio/soundcloud" + cmd = "xterm -e \"soundcli stream %srv\"" + + def __init__(self, *a, **kw): + conf.play.setdefault(self.fmt, self.cmd) + print self.module + conf.plugins[self.module] = False + + Index: contrib/reddit.py ================================================================== --- contrib/reddit.py +++ contrib/reddit.py @@ -1,10 +1,10 @@ # encoding: UTF-8 # api: streamtuner2 # title: reddit⛱ # description: Music recommendations from reddit /r/music and associated subreddits. -# version: 0.7 +# version: 0.8 # type: channel # url: http://reddit.com/r/Music # category: playlist # config: # { name: reddit_pages, type: int, value: 2, description: Number of pages to fetch. } @@ -16,12 +16,15 @@ # priority: extra # # Just imports Youtube links from music-related subreddits. # Those are usually new bands or fresh releases, or favorite # user selections. The category/subreddit list is filtered -# for a minimum quote of usable links (namely Youtube URLs, -# Soundcloud/Spotify/Bandcamp and weblinks aren't playable.) +# for a minimum quote of usable links (namely Youtube URLs). +# +# If you have a custom audio player available for Soundcloud, +# Spotify or Bandcamp, you can enable to retain such links. +# (For example configure `soundcli` for "audio/soundcloud".) # # This plugin currently uses the old reddit API, which might # be obsolete by August. It's thus a temporary channel, as # migrating to OAuth or regressing to plain HTML extraction # is not very enticing. @@ -44,10 +47,11 @@ # control attributes has_search = False listformat = "srv" audioformat = "video/youtube" titles = dict(playing="submitter", listeners="votes", bitrate=False) + img_resize = 24 # scale down reddit preview `img` artwork # just subreddit names to extract from categories = [ # static radio list "radioreddit 📟", @@ -249,12 +253,12 @@ text_urls = re.findall("\]\((https?://(?:www\.)?youtu[^\"\'\]\)]+)", row.get("selftext", "")) url_ext = (re.findall("\.(\w+)$", row["url"]) or [None])[0] listformat = "href" state = "gtk-media-play" - # Youtube - if re.search("youtu", row["url"]): + # Youtube URLs + if re.search("youtu\.?be|vimeo|dailymotion", row["url"]): format = "video/youtube" listformat = "srv" # direct MP3/Ogg elif url_ext in ("mp3", "ogg", "flac", "aac", "aacp"): format = "audio/" + url_ext @@ -265,20 +269,31 @@ format = "audio/x-unknown" # links from selftext elif text_urls: row["url"] = text_urls[0] format = "video/youtube" - # filter out Soundcloud etc. - elif re.search("soundcloud|spotify|bandcamp", row["url"]): - if conf.kill_soundcloud: - continue - format = "url/http" + # check for specific web links (Soundcloud etc.) + else: listformat = "srv" - state = "gtk-media-pause" - # pure web links etc. - else: - continue + format = None + for urltype in ("soundcloud", "spotify", "bandcamp", "mixcloud"): + if row["url"].find(urltype) > 0: + # is a specific player configured? + fmt = "audio/" + urltype + if fmt in conf.play: + state = "gtk-media-forward" + format = fmt + # retain it as web link? + elif not conf.kill_soundcloud: + state = "gtk-media-pause" + format = "url/http" + break + # else skip entry completely + if not format: + log.DATA_SKIP(format, row["url"]) + continue + #log.DATA(format, row["url"]) # repack into streams list r.append(dict( title = row["title"], url = row["url"], @@ -285,10 +300,11 @@ genre = re.findall("\[(.+?)\]", row["title"] + "[-]")[0], playing = row["author"], listeners = row["score"], homepage = "http://reddit.com{}".format(row["permalink"]), img = row.get("thumbnail", ""), + #img_resize = 24, format = format, listformat = listformat, state = state, )) return r