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

⌈⌋ ⎇ branch:  streamtuner2


Check-in [db4dea4fcb]

Overview
Comment:Introduce SurfMusik.de channel (original on Ubuntu forums, a bit rewritten to accomodate that changed HTML and more categories)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: db4dea4fcb9720a7f4298cecd3a4dbf2982d2f55
User & Date: mario on 2014-05-13 18:18:04
Original Comment: Introduce SurfMusik.de channel (original on Ubuntu forums, a bit rewritten to accomodate that changed HTML and more categories)
Other Links: manifest | tags
Context
2014-05-13
19:58
Some surfmusik category fixes, support for TV channel retrieval check-in: 3e7da2fdba user: mario tags: trunk
18:18
Introduce SurfMusik.de channel (original on Ubuntu forums, a bit rewritten to accomodate that changed HTML and more categories) check-in: db4dea4fcb user: mario tags: trunk
18:16
Fix missing mygtk import check-in: 2ccad59967 user: mario tags: trunk
Changes

Added channels/surfmusik.png version [5e2643a190].

cannot compute difference between binary files

Added channels/surfmusik.py version [2f6f518fa6].



















































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# encoding: UTF-8
# api: streamtuner2
# title: SurfMusik
# description: Streams categorized by region and genre.
# version: 0.1
# type: channel
# category: radio
# author: gorgonz123
# source: http://forum.ubuntuusers.de/topic/streamtuner2-zwei-internet-radios-anhoeren-au/3/
#
#

import re
import ahttp as http
from config import conf
from channels import *



# Surfmusik sharing site
class surfmusik (ChannelPlugin):

    # description
    title = "surfmusik"
    module = "surfmusik"
    homepage = "http://www.surfmusik.de/"

    base = "http://www.surfmusik.de/"
    listformat = "url/http"

    categories = [
        "Genres",
        ["50ger 50s", "Dubstep", "Latin Jazz", "Schlager", "60get 60s", "Electronic", "Latino", "Sega", "70ger 70s", "Eurodance ", "Lounge", "Soft", "80ger 80s", "Filmmusik", "Metal", "Sport", "90ger 90s", "Flamenco", "Merengue", "Swing", "Acid", "Gay", "Mix", "Tamil", "Ambient", "Gospel", "New Age", "Tango", "Arabische Musik", "Gothic", "News", "Techno", "Afrikanische Musik", "Groove", "Nostalgie", "Gabber", "Artist Radio ", "Halloween", "Oktoberfest", "Hardstyle", "Bachata", "Hip Hop", "Oldies", "Jumpstyle", "Bhangra", "Hoerspiel Radio", "Poli", "Minimal", "Balladen", "House", "Pop", "Schranz", "Big Band", "Indian", "Punk", "Top 40", "Blues", "Indisch", "Radioversprecher", "Trance", "Bollywood", "Instrumentalmusik", "Reggae", "Trip Hop", "Campusradio", "Information", "RnB", "Tropical", "Celtic", "Italo Disco ", "Rochester", "Urban", "Chillout", "Jazz", "Rock", "Variety", "Country", "Karnevalsmusik", "Rock n Roll", "Volksmusik", "Dance", "Kinderradio", "Rumba/Salsa", "Zumba", "Discofox", "Kirchlich", "Russische Chansons", "Drum n Bass", "Klassik", "Salsa"],
        "Deutschland", ["Baden Wuerttemberg", "Niedersachsen", "Bayern", "Nordrhein-Westfalen", "Berlin", "Rheinland-Pfalz", "Brandenburg", "Saarland", "Bremen", "Sachsen", "Hamburg", "Sachsen-Anhalt", "Hessen", "Schleswig-Holstein", "Mecklenburg-Vorpommern", "Thueringen"],
        "Europa", ["Albanien", "Griechenland", "Mallorca", "Slowakei", "Andorra", "Irland", "Malta", "Slovenien", "Armenien", "Island", "Niederlande", "Spanien", "Aserbaidschan", "Italien", "Norwegen", "Tschech. Republ", "Belgien", "Kasachstan", "Oesterreich", "Türkei", "Bosnien", "Kanarische Inseln", "Polen", "Ungarn", "Bulgarien", "Kirgistan", "Portugal", "Ukraine", "Daenemark", "Kroatien", "Rumaenien", "Wales", "Deutschland", "Lettland", "Russland", "Weissrussland", "England", "Liechtenstein", "Schottland", "Zypern", "Estland", "Litauen", "Schweden", "Finnland", "Luxemburg", "Schweiz", "Frankreich", "Mazedonien", "Serbien"],
        "Afrika", ["Angola", "Malawi", "Aethiopien", "Mauritius", "Ägypten", "Marokko", "Algerien", "Namibia", "Benin", "Nigeria", "Burundi", "Reunion", "Elfenbeinkueste", "Senegal", "Gabun", "Simbabwe", "Ghana", "Somalia", "Kamerun", "Sudan", "Kap Verde", "Suedafrika", "Kenia", "Tansania", "Kongo", "Togo", "Libyen", "Tunesien", "Madagaskar", "Uganda", "Mali"],
        "USA", ["Alabama", "Illinois", "Montana", "Rhode Island", "Alaska", "Indiana", "Nebraska", "South Carolina", "Arizona", "Iowa", "Nevada", "South Dakota", "Arkansas", "Kansas", "New Hampshire", "Tennessee", "Californien", "Kentucky", "New Jersey", "Texas", "Colorado", "Louisiana", "New Mexico", "Utah", "Connecticut", "Maine", "New York", "Vermont", "Delaware", "Maryland", "North Carolina", "Virginia", "Distr.Columbia", "Massachusetts", "North Dakota", "Washington", "Florida", "Michigan", "Ohio", "West Virginia", "Georgia", "Minnesota", "Oklahoma", "Wisconsin", "Hawaii", "Mississippi", "Oregon", "Wyoming", "Idaho", "Missouri", "Pennsylvania", "NOAA Wetter Radio"],
        "Kanada", ["Alberta", "Ontario", "British Columbia", "Prince Edward Island", "Manitoba", "Québec", "Neufundland", "Saskatchewan", "New Brunswick", "Nordwest-Territorien", "Nova Scotia", "Yukon", "Nunavut",],
        "Amerika", ["Mexiko", "Costa Rica", "Argentinien", "Aruba", "El Salvador", "Bolivien", "Antigua", "Guatemala", "Brasilien", "Barbados", "Honduras", "Chile", "Bahamas", "Nicaragua", "Ecuador", "Bermuda", "Panama", "Franz. Guyana", "Curaçao", "Guyana", "Domenik. Republ", "Kolumbien", "Grenada", "Paraguay", "Guadeloupe", "Uruguay", "Haiti", "Suriname", "Jamaika", "Peru", "Kaimaninseln", "Venezuela", "Kuba", "Martinique", "Puerto Rico", "St.Lucia", "Saint Martin", "Trinidad und Tobago"],
        "Asien",
        "Ozeanien",
        "SurfTV",
        ["MusikTV", "NewsTV"],
    ] 
    titles = dict( genre="Genre", title="Station", playing="Location", bitrate=False, listeners=False )
 
    config = [
    ]    


    # refresh category list
    def update_categories(self):
        pass


    # download links from surfmusik listing
    def update_streams(self, cat, force=0):

        entries = []
        i = 0
        max = int(conf.max_streams)
        
        # placeholder category
        if cat in ["Genres"]:
            src = ""
        # tv
        elif cat in ["SurfTV", "MusikTV", "NewsTV"]:
            src = self.base + "" + cat.lower() + ".html"
        # genre 
        elif cat in self.categories[1]:
            src = self.base + "genre/" + cat.lower() + ".html"
        # country
        else:
            src = self.base + "land/" + cat.lower() + ".html"
        
        if src:    
            html = http.get(src)
        
            rx_current = re.compile(r"""
                <a\s+class="navil"\s+href="([^"]+)"[^>]*>([^<>]+)</a></td>
                <td\s+class="ort">(.*?)</td>.*?
                <td\s+class="ort">(.*?)</td>.*?
                <td\s+class="home1"><a\s+class="navil"\s+href="(.+?)"
            """, re.X|re.I)

            # per-country list
            for uu in rx_current.findall(html):
                (homepage, name, genre, stadt, url) = uu

                entries.append({
                    "title": name,
                    "homepage": homepage,
                    "url": "http://www.surfmusik.de/m3u/" + url[30:-5] + ".m3u",
                    "playing": stadt,
                    "genre": genre,
                })

                if i > max:
                   break
                i += 1
 
        # done    
        return entries