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

⌈⌋ branch:  streamtuner2


Diff

Differences From Artifact [74725ffeda]:

To Artifact [46f1758ac3]:

  • File contrib/reddit.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: 15327) [annotate] [blame] [check-ins using]

1
2
3
4
5
6
7
8
9
10
11

12
13
14
15
16
17
18
1
2
3
4
5
6
7
8
9
10

11
12
13
14
15
16
17
18










-
+






# encoding: UTF-8
# api: streamtuner2
# title: reddit⛱
# description: Music recommendations from reddit /r/music and associated subreddits.
# 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. }
#   { name: kill_soundcloud, type: boolean, value: 1, description: Filter soundcloud/spotify/etc if there's no player configured. }
#   { name: filter_walledgardens, type: boolean, value: 1, description: Filter walled gardens (soundcloud/spotify/…) if there's no player. }
#   { name: reddit_keep_all, type: boolean, value: 0, description: Keep all web links (starts a browser for websites/news). }
# png:
#   iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJ1BMVEUAAAAcICX/AABHSk1jZ299hYz/bmajq6//lY/d0M3C1+3T7P38+/iaLhuGAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgF
#   HUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQffBRUXIyQbWArCAAAAh0lEQVQI12Pg3g0BDLtXrVq1eveq3Qy7gIxCU9dqEGO11/ZKbzBDenUIUM3u7cGi1UDFW0TE55wsdpZikAw/
#   eebMnMmHGVxqDuUc0zzpynD4zIk5J3vOSDNsOQMG1gy7bI5HTq85Ws2wu/jM9PIzrkArdhmXlzuuXg00eVd5+epVqxmgrtgNAOWeS1KYtcY4AAAAAElFTkSuQmCC
# priority: extra
#
31
32
33
34
35
36
37

38
39
40
41
42
43
44
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45







+






# is not very enticing.


import json
import re
from config import *
from channels import *
import action
import ahttp


# reddit.com
#
# Uses old API requests such as:
#  → http://www.reddit.com/r/music/new.json?sort=new
275
276
277
278
279
280
281


282

283
284
285
286
287
288
289
290
291
292









293
294
295
296
297
298
299
300
276
277
278
279
280
281
282
283
284

285










286
287
288
289
290
291
292
293
294

295
296
297
298
299
300
301







+
+
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-






            elif text_urls:
                row["url"] = text_urls[0]
                format = "video/youtube"
            # check for specific web links (Soundcloud etc.)
            else:
                listformat = "srv"
                format = None
                # look for walled gardens
                urltype = re.findall("([\w-]+)\.\w+/", row["url"] + "/x-unknown.com/")[0]
                for urltype in ("soundcloud", "spotify", "bandcamp", "mixcloud"):
                if 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"
                    # is a specific player configured?
                    fmt = "audio/" + urltype
                    if fmt in conf.play or fmt in action.handler:
                        state = "gtk-media-forward"
                        format = fmt
                    # retain it as web link?
                    elif not conf.filter_walledgardens:
                        state = "gtk-media-pause"
                        format = "url/http"
                        break
                # else skip entry completely
                if not format:
                    if conf.reddit_keep_all:
                        state = "gtk-page-setup"
                        format = "url/http"
                    else:
                        log.DATA_SKIP(format, row["url"])