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

⌈⌋ ⎇ branch:  streamtuner2


Check-in [fa19c2995e]

Overview
Comment:New channel housemixes.com added.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: fa19c2995ea99dd22c5491b91eae3bee4993bfa2
User & Date: mario on 2016-10-08 03:32:27
Other Links: manifest | tags
Context
2016-10-08
04:07
Fix HTML assembling (<body>.+?</body> cleanup for PyQuery to see all entries). check-in: ea2010c673 user: mario tags: trunk
03:32
New channel housemixes.com added. check-in: fa19c2995e user: mario tags: trunk
2016-09-25
17:56
Minor text fixes. Compacted "configuration" back into features topic. check-in: cb5846cb2d user: mario tags: trunk
Changes

Added contrib/housemixes.py version [f5965e2332].























































































































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
106
107
108
109
110
111
112
113
114
115
116
117
118
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# api: streamtuner2
# title: house-mixes.com
# description: UK DJs house/techno mixes
# type: channel
# category: archive
# version: 0.3
# url: http://www.house-mixes.com/
# config: -
# priority: contrib
# png:
#    iVBORw0KGgoAAAANSUhEUgAAABgAAAAVCAIAAADTi7lxAAAABGdBTUEAALGPC/xhBQA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BC0lSgU1vwPfFn3ziLk1zUH8IgyPsDWNXM3kiaL2Pv3wIGv6Pt2+3JzvsfTf0IpgSl+6RdvSOzEvj4gR2DwXDfo+mtMRkx7kBtA/gjJsJiDIYqOtkg8EACERwu91utzvTSld6yWNS
#    XYeEplSiojwbEhIS9tcdNAzzw81bnlzWwzM+UkohhCTKjhNpVqkpXUopA1FzMEyhUCglJblicYUAGhsb/X6/JsVEq5gQyykxiNdF0IDBYOb0SVnTyqa63W6DeSgMf4SlFFJKyaY5+l28/uDz8xc8V1rS2dl54/r1VAu2luPtEqzMw4vpaOunvoBpsVjeWb9eCNHW1jZamghCCCilxgoDqN6wMRyJNF24MLmoWCeU2sWCiWLBRDEjVcRpAGhV5eofjvyYnZOLcdMqpZ4GpaSk1NfXh8Lh7+q/T3M6MS5CyKXLV1xsvvxq1Wo8+WZPg0ZZ
#    ubm5DQ0NwWDw1JkzS5a+NCkrKzXNWVhUVFNT03Xr9uYtW2Ot1v+DnjDkmG0zMzNrNm167Y21SqCjs3No2JudlQkhv969u+HwYZ/PO16PDw35lLNHYxhGQmLi7Dlzly6uyM/PF0TX29tPnjp95fJvzDzWfbyz/wNZXAuckyZkmAAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxNi0xMC0wOFQwNDozMDo1NCswMjowMFEBTy0AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTYtMTAtMDhUMDQ6MzA6NTQrMDI6MDAgXPeRAAAAGXRFWHRTb2Z0d2Fy
#    ZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAABJRU5ErkJggg==
# depends: pq, ahttp
#
# House-mixes.com is an UK platform for DJs to showcase their
# house/dance/techno mixes.
#


import ahttp
from pq import pq
import re
from config import *
from channels import *
import channels



# House-Mixes
#
class housemixes(channels.ChannelPlugin):

    # attrs
    base_url = "http://www.house-mixes.com"
    listformat = "pls"
    has_search = False
    titles = dict(playing = "Artist", bitrate=False)
    img_resize = 32
    
    # categories
    catmap = {"Ambient / Chillout": "/djmixes/chillout-dj-mixes", "Bassline House / Speed Garage / 4x4": "/djmixes/bassline-house-dj-mixes", "Breakbeat": "/djmixes/breakbeat-dj-mixes", "Chicago House": "/djmixes/chicago-house-dj-mixes", "Commercial House": "/djmixes/commercial-house-dj-mixes", "Darkstep": "/djmixes/darkstep-dj-mixes", "Deep House": "/djmixes/deep-house-dj-mixes", "Deep Tech House": "/djmixes/deep-tech-house-dj-mixes", "Detroit Techno": "/djmixes/destroit-techno-dj-mixes", "Drum n Bass": "/djmixes/dnb-dj-mixes", "Dub": "/djmixes/dub-dj-mixes", "Dub Techno": "/djmixes/dub-techno-dj-mixes", "Dubstep": "/djmixes/dub-step-dj-mixes", "Electro House": "/djmixes/electro-house-dj-mixes", "Fidget House": "/djmixes/fidget-house-dj-mixes", "Funk / Disco / Nu-Disco": "/djmixes/funk-disco-dj-mixes", "Funky House": "/djmixes/funky-house-dj-mixes", "Goa Trance": "/djmixes/goa-trance-dj-mixes", "Hard House / Hard Dance": "/djmixes/hardhouse-dj-mixes", "Hardcore Gabber": "/djmixes/hardcore-gabber-dj-mixes", "Hardstyle": "/djmixes/hardstyle-dj-mixes", "House": "/djmixes/house-dj-mixes", "Intelligent Drum n Bass": "/djmixes/intelligent-dnb-dj-mixes", "Jackin House": "/djmixes/jackin-house-dj-mixes", "Jump Up": "/djmixes/jumpup-dnb-dj-mixes", "Jungle": "/djmixes/jungle-dnb-dj-mixes", "Latin House": "/djmixes/latin-dj-mixes", "Liquid Drum n Bass": "/djmixes/liquid-dnb-dj-mixes", "Mash-Ups": "/djmixes/Mash-Ups-dj-mixes", "Minimal / Techno": "/djmixes/minimal-techno-dj-mixes", "Mixed Genre": "/djmixes/mixed-genre-dj-mixes", "Neurofunk": "/djmixes/neurofunk-dj-mixes", "Old Skool": "/djmixes/old-skool-dj-mixes", "Original Productions": "/djmixes/productions-dj-mixes", "Progressive House": "/djmixes/progressive-house-dj-mixes", "Progressive Trance": "/djmixes/progressive-trance-dj-mixes", "Psy  Trance": "/djmixes/psy-trance-dj-mixes", "Reggae": "/djmixes/reggae-dj-mixes", "Remixes": "/djmixes/Remixes-dj-mixes", "RnB / Hip Hop": "/djmixes/hiphop-dj-mixes", "Soulful House": "/djmixes/soulful-house-dj-mixes", "Tech House": "/djmixes/tech-house-dj-mixes", "Techno": "/djmixes/techno-dj-mixes", "Techstep": "/djmixes/techstep-dj-mixes", "Trance": "/djmixes/trance-dj-mixes", "Trap": "/djmixes/trap-dj-mixes", "Tribal House": "/djmixes/tribal-dj-mixes", "Trip Hop": "/djmixes/trip-hop-dj-mixes", "Tropical House": "/djmixes/tropical-house-dj-mixes", "UK Funky": "/djmixes/uk-funky-dj-mixes", "UK Garage": "/djmixes/uk-garage-dj-mixes", "UK Hardcore": "/djmixes/uk-hardcore-dj-mixes", "Uplifting Trance": "/djmixes/uplifting-trance-dj-mixes", "Urban": "/djmixes/urban-dj-mixes", "Vocal  Trance": "/djmixes/vocal-trance-dj-mixes"}
    categories = ["Drum n Bass", ["Darkstep", "Intelligent Drum n Bass", "Jump Up", "Jungle", "Liquid Drum n Bass", "Neurofunk", "Techstep"], "House", ["Ambient / Chillout", "Chicago House", "Commercial House", "Deep House", "Deep Tech House", "Electro House", "Fidget House", "Funk / Disco / Nu-Disco", "Funky House", "Jackin House", "Latin House", "Progressive House", "Soulful House", "Tech House", "Tribal House", "Tropical House"], "Mash-Ups", [], "Mixed Genre", [], "Old Skool", [], "Original Productions", [], "Remixes", [], "Techno", ["Detroit Techno", "Dub Techno", "Dub Techno", "Hard House / Hard Dance", "Hardcore Gabber", "Hardstyle", "Minimal / Techno", "UK Hardcore"], "Trance", ["Goa Trance", "Progressive Trance", "Psy  Trance", "Uplifting Trance", "Vocal  Trance"], "Urban", ["Bassline House / Speed Garage / 4x4", "Breakbeat", "Dub", "Dubstep", "Reggae", "RnB / Hip Hop", "Trap", "Trip Hop", "UK Funky", "UK Garage"]]
    
    # redefine
    streams = {}
    
        
    # Update cat list
    def update_categories(self):
        self.categories = []

        # Fetch /mixes to scan genres
        html = ahttp.get(self.base_url + "/mixes")
        #log.DATA( html )
        for group in pq(html)("ul.genre-nav > li"):

            a = pq(group)("a")[0]
            print a.text
            self.categories.append(a.text)
            self.catmap[a.text] = a.attrib["href"]
            subs = []
            
            for a in pq(group)("ul > li > a"):
                subs.append(a.text)
                self.catmap[a.text] = a.attrib["href"]
            
            self.categories.append(subs)
        

    # downloads stream list from shoutcast for given category
    def update_streams(self, cat):
        streams = []
        if not cat in self.catmap:
            return

        # collect
        html = ahttp.get(self.base_url + self.catmap[cat])
        for i in range(2, int(conf.max_streams)/50): #conf.housemixes_pages):
            if html.find("latest/" + str(i)):
                html = html + ahttp.get(self.base_url + self.catmap[cat] + "/latest/%s" % i)
        html = re.sub("</body>.+<body>", "", html, 100, re.S)
        
        # extract
        for card in [pq(e) for e in pq(html)(".card-audio")]:
            r = {
                "title": card(".card-audio-title span").text(),
                "playing": card(".card-audio-user a").text(),
                "genre": card(".card-tags a span").text(),
                # url will be substitute later
                "url": self.base_url + card(".audio-image-link").attr("href"),
                "homepage": self.base_url + card(".audio-image-link").attr("href"),
                # standard size 318x318 loads quicker
                "img": card(".audio-image-link img").attr("src"), # re.sub("=318&", "=32&",  ...)
                "listeners": int(card("a.card-plays").text()),
            }
            streams.append(r)

        #log.DATA( streams )
        return streams


    # Hook `url` access, look up actual mp3 file
    def row(self):
        r = ChannelPlugin.row(self)
        url = r.get("url")
        if url and url.find("/profile/") > 0:
            print url
            html = ahttp.get(url)
            ls = re.findall(r""" Mp3Url [\\\\:"]+ (http[^\\\\"]+) """, html, re.M|re.X)
            print ls
            if ls:
                r["url"] = ls[0]
        return r