Index: contrib/streema.py ================================================================== --- contrib/streema.py +++ contrib/streema.py @@ -1,11 +1,11 @@ # api: streamtuner2 # title: Streema # description: Directory and app for over 70.000 stations # type: channel # category: radio -# version: 0.3 +# version: 0.4 # url: http://www.streema.com/ # png: # iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABF0lEQVR42oWTMWsCURCE/Y/Bxh+QLrUIloKdELCxTOOBRSSgpZVYhCAWCtcEETGQJmCTkG7k47HcereeA4vnu32zszt7jceRFMXDQGoN # pd40RXci9d+kpxep+VzkNaLLXBzMpe1R+vu/jq8fabxKOSEBL6YfqgVEnSwgsMoen9+JcJlL5990xv9QAYf5qbhMC/RrQf/trLgctoA8A/0yPCO38PkVApPpAdFsndyoJeDlaKFarPZ3FJj3i12qHIEh # sichgSfi18j8bHDmpgvlQfFMNe/O5hAoMOnMoJMVRNjHCnsFbGKFgCl7IJPloZoHLrEPlRYi+8ogh724uUiv72ny0QeEQl+5QmDDIomeLVhdzuzzLrt1AQVnVKF/yji7AAAAAElFTkSuQmCC @@ -13,21 +13,21 @@ # priority: optional # extraction-method: regex, action-handler # # Streema lists over 70000 radio stations. Requires a double lookup # however, as stream addresses are embedded in the web player only. -# It does only poll one page of results. +# Channel only polls one page of results, skips external stream pages. # # Currently playing field is quite spotty. No homepages are listed. # The category map is prepared here, because it's quite slow to # update. Region/city categories are left unused. # # The server search function is implemented however. # -import re +import re, traceback import ahttp from config import * from channels import * @@ -69,11 +69,11 @@ # split into blocks for html in re.split(']+?(?:data-role="player-popup"|class="item")', html): # not very efficient - url = re.findall('data-url="/radios/play/(\d+)"', html) + url = re.findall('data-url="/radios/play/([\w_.-]+)"', html) # skips external-stream-tab http:// entries homepage = re.findall('data-profile-url="/radios/(.+?)"', html) title = re.findall('title="Play (.+?)"', html) img = re.findall('(.*?)', html, re.S) genre = re.findall('

(.*?)

', html, re.S) @@ -90,10 +90,12 @@ playing = playing[0], genre = unhtml(genre[0]), listeners = to_int(listeners[0]) )) except: + #log.E(e) + #traceback.print_exc() pass #some field missing # done return r @@ -102,10 +104,17 @@ def resolve_urn(self, row): if row.get("url", "-").find("urn:streema:") != 0: return id = row["url"][12:] html = ahttp.get("http://streema.com/radios/play/%s" % id) - url = re.findall('