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

⌈⌋ ⎇ branch:  streamtuner2


Check-in [8dfd60898f]

Overview
Comment:Catch http/json result errors earlier. Break on absent "after" id.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8dfd60898f309b3f9fc09e0c9375d64e1b68db7c
User & Date: mario on 2015-05-22 22:01:25
Other Links: manifest | tags
Context
2015-05-23
01:08
Add more subreddits to category list. Placeholder groups with "→" decorator. Allow web-only links per config option (start web browser for sptfy/sndcl etc.) check-in: 3746af529b user: mario tags: trunk
2015-05-22
22:01
Catch http/json result errors earlier. Break on absent "after" id. check-in: 8dfd60898f user: mario tags: trunk
22:00
Support config option boolean aliases (1, true, yes, on). check-in: effbfc31f1 user: mario tags: trunk
Changes

Modified contrib/reddit.py from [64c5bb569c] to [a40c90e15d].

1
2
3
4
5
6
7
8
9
10
11
12
# encoding: UTF-8
# api: streamtuner2
# title: redditâ›±music
# description: Music recommendations from reddit /r/music etc.
# version: 0.5
# 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 links (no player configurable). )
# png:



|
|







1
2
3
4
5
6
7
8
9
10
11
12
# encoding: UTF-8
# api: streamtuner2
# title: redditâ›±music
# description: Music recommendations from reddit /r/music and associated subreddits.
# version: 0.6
# 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 links (no player configurable). )
# png:
94
95
96
97
98
99
100
101
102
103
104
105
106
107

108


109

110



111


112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139

140
141
142
143
144
145
146
        
        # radioreddit
        if cat == "radioreddit":
           return self.radioreddit()

        # collect links
        data = []
        after = ""
        for i in range(1, int(conf.reddit_pages) + 1):
            j = json.loads(ahttp.get(
                "http://www.reddit.com/r/{}/new.json?sort=new&after={}".format(
                    cat.lower(), after
                )
            ))

            if not j.get("data",[]).get("children"):


                break

            data += j["data"]["children"]



            after = j["data"]["after"]



        # convert
        r = []
        for row in (ls["data"] for ls in data):

            # find links in text posts
            text_urls = re.findall("\]\((https?://(?:www\.)?youtu[^\"\'\]\)]+)", row.get("selftext", ""))
            url_ext = (re.findall("\.(\w+)$", row["url"]) or [None])[0]
            listformat = "href"

            # Youtube
            if re.search("youtu", row["url"]):
                format = "video/youtube"
                listformat = "srv"
            # direct MP3/Ogg
            elif url_ext in ("mp3", "ogg", "flac", "aac", "aacp"):
                format = "audio/" + url_ext
                listformat = "srv"
                print row
                print url_ext
            # playlists?
            elif url_ext in ("m3u", "pls", "xspf"):
                listformat = url_ext
                format = "audio/x-unknown"
                print url_ext
            # links from selftext
            elif text_urls:
                row["url"] = text_urls[0]

            # filter out Soundcloud etc.
            else:
                continue

            # repack into streams list
            r.append(dict(
                title = row["title"],







|

|
|
|
|
<
>
|
>
>

>
|
>
>
>
|
>
>


















<
<




<



>







94
95
96
97
98
99
100
101
102
103
104
105
106

107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137


138
139
140
141

142
143
144
145
146
147
148
149
150
151
152
        
        # radioreddit
        if cat == "radioreddit":
           return self.radioreddit()

        # collect links
        data = []
        after = None
        for i in range(1, int(conf.reddit_pages) + 1):
            j = ahttp.get(
                "http://www.reddit.com/r/{}/new.json".format(cat.lower()),
                { "sort": "new", "after": after }
            )

            try:
                j = json.loads(j)
            except Exception as e:
                log.ERR("Reddit down?", e)
                break
            if j.get("data",[]).get("children"):
                data += j["data"]["children"]
            else:
                break
            if j.get("data",[]).get("after"):
                after = j["data"]["after"]
            else:
                break

        # convert
        r = []
        for row in (ls["data"] for ls in data):

            # find links in text posts
            text_urls = re.findall("\]\((https?://(?:www\.)?youtu[^\"\'\]\)]+)", row.get("selftext", ""))
            url_ext = (re.findall("\.(\w+)$", row["url"]) or [None])[0]
            listformat = "href"

            # Youtube
            if re.search("youtu", row["url"]):
                format = "video/youtube"
                listformat = "srv"
            # direct MP3/Ogg
            elif url_ext in ("mp3", "ogg", "flac", "aac", "aacp"):
                format = "audio/" + url_ext
                listformat = "srv"


            # playlists?
            elif url_ext in ("m3u", "pls", "xspf"):
                listformat = url_ext
                format = "audio/x-unknown"

            # links from selftext
            elif text_urls:
                row["url"] = text_urls[0]
                format = "video/youtube"
            # filter out Soundcloud etc.
            else:
                continue

            # repack into streams list
            r.append(dict(
                title = row["title"],