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

⌈⌋ ⎇ branch:  streamtuner2


Check-in [7ef8a2b827]

Overview
Comment:Add generic bitrate filter plugin, move functionality out of xiph channel.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7ef8a2b827fc12f9008af0ff46f27e990bf4bbf1
User & Date: mario on 2015-05-12 20:05:52
Other Links: manifest | tags
Context
2015-05-12
22:17
Add plugin defaults (for newly added options, but previously active modules) in any case when starting with -D flag. Save settings.json in json.dumps(sort_keys=True) mode. check-in: 3497339549 user: mario tags: trunk
20:05
Add generic bitrate filter plugin, move functionality out of xiph channel. check-in: 7ef8a2b827 user: mario tags: trunk
20:03
Remove plugin #color: check-in: b4558a4599 user: mario tags: trunk
Changes

Added channels/filter_bitrate.py version [123128ab48].
















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# encoding: UTF-8
# api: streamtuner2
# title: Filter Bitrate
# description: Cleans up low-quality entries from all station lists.
# version: 0.1
# type: filter
# category: audio
# priority: optional
# config:
#   { name: min_bitrate_mp3, value: 32, type: select, select: "32|48|64|80|96|112|128|144|160", description: Filter MP3 streams with lesser audio quality. }
#   [ name: min_bitrate_ogg, value: 32, type: select, select: "32|48|64|80|96|112|128|144|160", description: OggVorbis/AAC sound ok with slightly lower bitrates still. ]
# hooks: -
#
# Plugin that filters radio stations on bitrate (audio quality).
# Anything below 64 kbit/s often sounds awful for MP3 streams.
# While AAC or Ogg Vorbis might still be acceptable sometimes.
#
# This functionality was previously just implemented for the Xiph
# plugin. It's now available as generic filter for all channels.
# Beware that some channels provide more entries with low bitrates,
# thus might appear completely empty.


from config import *
import channels


# Filter streams by bitrate
class filter_bitrate():

    meta = plugin_meta()
    module = "filter_bitrate"

    # Hijack GenericChannel.prepare
    def __init__(self, parent):
        channels.GenericChannel.postprocess_filters.append(self.filter_rows)

    # filter bitrate
    def filter_rows(self, row):
        b = int(row.get("bitrate", 0))
        if b <= 10:
            return True
        elif b < int(conf.min_bitrate_mp3):
            return False
        else:
            return True

Modified channels/xiph.py from [43c0a4353b] to [8fa7c91382].

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

10
11
12
13
14
15
16









-







# encoding: UTF-8
# api: streamtuner2
# title: Xiph.org
# description: ICEcast radios. Scans per JSON API, slow XML, or raw directory.
# type: channel
# url: http://dir.xiph.org/
# version: 0.5
# category: radio
# config: 
#    { name: xiph_min_bitrate, value: 64, type: int, description: "Minimum bitrate; filter lesser quality streams.", category: filter }
#    { name: xiph_source, value: web, type: select, select: "cache=JSON cache srv|xml=Clunky XML blob|web=Forbidden fruits", description: "Source for station list extraction." }
# priority: standard
# png:
#   iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAg5JREFUOI2lk1tIE2AUx3+7CG1tlmlG1rSEHrKgEUF7yO40taQiRj10I4qKkOaT4hIUItuTkC8hpJAQtJCICrFpzEKw
#   h61eQorGNBOTzbEt16ZrnR5Wq3mZD/3heziX//983znngyyov+eSbHEA5WKBhs4BKVy9gsqajqwiCwo0dA5IQX5u2s4moliMPPV1nCeDzxgNBFDHE2wsKMPzsGVefobjcnO7RMfeMuL341ZBrNEGRmPqqjdvsbbf
#   w7irO4Oj+rdywNNNucmERsLUVndR8uYRU13PCew6hpgP8W02xMpIsik++qk5oweW6y3yob8WnXacZDKJWh1Cp4OtRUHsh19TUlUGViv09RGqKAenU5QnLKm+rK88LjgcUnxmr/h8iNO5XYJBRAQZ/qiVeptGWjty
#   5cClDWLwugQRIRiU5UdPCoD6S89jhV6pks9WG6fuwtBtF5v72vC1v+B86SsM+jD56hjnyiM0lRrAbofeXjQJLdE/78jbXSU5166I6f5VeeDdKdq6GtlSd0QkVU+8XsQhlt9W6izbZ5aMKWgtp2WT/yUHd0xSYU7i
33
34
35
36
37
38
39
40

41
42

43
44
45
46
47
48
49
32
33
34
35
36
37
38

39


40
41
42
43
44
45
46
47







-
+
-
-
+







#    slow, then slices out genres. No search. With the secret
#    "buffy" mode keeps all streams buffered.
#
#  → "Forbidden Fruits" extracts from dir.xiph.org HTML pages,
#    with homepages and listener/max infos available. Also
#    enables live server searching.
#
# The bitrate filter can strip any low-quality entries, but
# The previous bitrate filter is now a separate plugin, but
# retains `0` entries (which just lack meta information and
# aren't necessarily low-bitrate.)
# available for all channels.


from config import *
from uikit import uikit
import ahttp
from channels import *
import xml.dom.minidom
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
84
85
86
87
88
89
90




91
92
93
94
95
96
97







-
-
-
-







      elif conf.xiph_source in ("xml", "buffy"):
          log.PROC("Xiph mode: xml.dom.minidom to traverse yp.xml")
          r = self.from_yp_xml(cat, search)
      else:
          log.PROC("Xiph mode: extract from dir.xiph.org HTML listings")
          r = self.from_raw_html(cat, search)
          
      # filter bitrate
      if conf.xiph_min_bitrate:
          r = [row for row in r if row.get("bitrate", 0) <= 10 or row.get("bitrate", 0) >= int(conf.xiph_min_bitrate)]

      return r
      



  # Retrieve partial stream list from api.include-once.org cache / JSON API wrapper
  #