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

⌈⌋ ⎇ branch:  streamtuner2


Check-in [80f3cdf4c2]

Overview
Comment:Workaround plugin for RadioSure multi-URL entries.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 80f3cdf4c29829e03d953e44e4295a0319f2f917
User & Date: mario on 2016-11-13 13:23:52
Other Links: manifest | tags
Context
2016-11-13
13:30
Update some feature plugin docs. check-in: 76f59fe4db user: mario tags: trunk
13:23
Workaround plugin for RadioSure multi-URL entries. check-in: 80f3cdf4c2 user: mario tags: trunk
13:23
action: optionalize quoting for BSD/Linux if plain http:// url without special chars. And fix regex to properly caret-escape + quote for Windows. check-in: 52f8cb3961 user: mario tags: trunk
Changes

Added contrib/tmp_clean_multiurl.py version [d5e6d3c789].







































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
# encoding: utf-8
# title: TMP: clean Multi-URLs
# description: Strips multiple stream URLs from stations (for RadioSure mostly)
# version: 0.1
# depends: streamtuner2 >= 2.2.0, streamtuner2 < 2.2.1
# type: feature
# category: filter
#
# While action.py does not yet support space-separated URL lists in station
# entries, this plugin cleans them up. It strips anything but the first URL.


import re
from channels import GenericChannel
from config import log, conf


# filter
class tmp_clean_multiurl(object):
    module = __name__
    rx_space = re.compile(r"\s")
    rx_nonurl = re.compile(r"(^|\s)(?!\w+:)\S+")

    # Hook
    def __init__(self, parent):
        GenericChannel.postprocess_filters.append(self.filter_rows)

    # does not omit any rows, just updated `url` field
    def filter_rows(self, row, channel):
        urls = row.get("url", "")
        if re.search(self.rx_space, urls):
            urls = urls.strip()
            urls = re.sub(self.rx_nonurl, "", urls)
            row["url"] = urls.strip().split(" ")[0]
        return True