From e704dffe176495022a99848440b10476cdb7e31d Mon Sep 17 00:00:00 2001 From: idleloop-github Date: Tue, 8 Jan 2019 22:31:59 +0100 Subject: [PATCH] v1.3.2: patched Places; Featured cams extended --- README.md | 6 ++--- addon.xml | 2 +- changelog.txt | 4 ++++ channel.py | 55 +++++++++++++++++++++++++++++--------------- core/scrapertools.py | 2 +- 5 files changed, 46 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 338404e..05eef18 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,10 @@ EarthCam.com is the premiere network of scenic webcams and offers a complete dat ### Installation -* [download released zip](https://github.com/idleloop-github/xbmc-earthcam/releases/download/v1.3.1/plugin.video.earthcam-1.3.1.zip) +* [download released zip](https://github.com/idleloop-github/xbmc-earthcam/releases/download/v1.3.2/plugin.video.earthcam-1.3.2.zip) * Kodi/XBMC: System / Add-ons / Install from zip file / * or Kodi 17: Add-ons / Download / ".." / Install from zip file / -* select [earthcam's zip file](https://github.com/idleloop-github/xbmc-earthcam/releases/download/v1.3.1/plugin.video.earthcam-1.3.1.zip) +* select [earthcam's zip file](https://github.com/idleloop-github/xbmc-earthcam/releases/download/v1.3.2/plugin.video.earthcam-1.3.2.zip) * Note that Kodi will complain about installing from "Unknown sources": in this case, activate this option, and repeat the installation steps. From version 1.2.0 on, this add-on can play [HLS streams](https://en.wikipedia.org/wiki/HTTP_Live_Streaming), and this mode is more stable than [RTMP](https://en.wikipedia.org/wiki/Real-Time_Messaging_Protocol). @@ -28,7 +28,7 @@ Steps to install an **inputstream.rtmp** add-on from [kodinerds repo](https://gi * Download the appropriate *repository.kodinerds_X.zip* zip file for your platform [from here](https://github.com/kodinerds/binary-repo). * Install this repository on Kodi: Add-ons / Download / .. / Install from zip file / *and select kodiners' zip file*. Previously, "Unknown Sources" must have been activated on: Settings / System / Add-ons / Unknown sources * Install *inputstream.rtmp* add-on: Add-ons / Download / .. / Install from repository / kodinerds / VideoPlayer InputStream / RTMP Input -* and then, install *plugin.video.earthcam*: Add-ons / Download / .. / Install from zip file / select [earthcam's zip file](https://github.com/idleloop-github/xbmc-earthcam/releases/download/v1.3.1/plugin.video.earthcam-1.3.1.zip). +* and then, install *plugin.video.earthcam*: Add-ons / Download / .. / Install from zip file / select [earthcam's zip file](https://github.com/idleloop-github/xbmc-earthcam/releases/download/v1.3.2/plugin.video.earthcam-1.3.2.zip). ##### Enable HLS playing From version 1.2.0 on, this add-on can play [HLS streams](https://en.wikipedia.org/wiki/HTTP_Live_Streaming). diff --git a/addon.xml b/addon.xml index d0d93f1..3e46d64 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ diff --git a/changelog.txt b/changelog.txt index aca8ad7..656f729 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +v1.3.2 +(2019, Jan) +patched Places; Featured cams extended + v1.3.1 (2019, Jan) patched Search diff --git a/channel.py b/channel.py index 62dfd37..07c1220 100644 --- a/channel.py +++ b/channel.py @@ -43,9 +43,9 @@ def isGeneric(): def mainlist(item): - logger.info("[channel.py] mainlist") + if (DEBUG): ("[channel.py] mainlist") itemlist=[] - itemlist.append( Item(action="cams", title="Featured Cams" , url=URL ) ) + itemlist.append( Item(action="cams", title="Featured Cams" , url=PLACES_URL ) ) itemlist.append( Item(action="places", title="Places" , url=PLACES_URL ) ) itemlist.append( Item(action="searching", title="Search" , url='' ) ) return itemlist @@ -107,16 +107,16 @@ def _get_category(item, category): divs = parseDOM( html, 'div', attrs={'class': r'[^\'"]*?col\-xs\-12' } ) zone = parseDOM( html, 'p', attrs={ 'class': 'pageTitle' } )[0].replace(':', '') for _id, div in enumerate( divs ): - thumbnail = parseDOM( div, 'img', ret='src' )[0].replace('256x144', '512x288').replace('128x72', '256x144') - url = parseDOM( div, 'a', ret='href' )[0] - title = parseDOM( div, 'span', attrs={'class': 'featuredTitle'} )[0] - location = parseDOM( div, 'div', attrs={ 'class': 'featuredCity' } )[0] + ', ' + zone - plot = title + "\n(" + location + ')' - if plot == None: plot='' - if (DEBUG): logger.info("%s, %s, %s, %s, %s" % (title, thumbnail, url, location, plot)) - item=Item(action="play", title=title, url=url, thumbnail=thumbnail, - fanart=thumbnail, plot=plot ) - itemlist.append( item ) + thumbnail = parseDOM( div, 'img', ret='src' )[0].replace('256x144', '512x288').replace('128x72', '256x144') + url = parseDOM( div, 'a', ret='href' )[0] + title = parseDOM( div, 'span', attrs={'class': 'featuredTitle'} )[0] + location = parseDOM( div, 'div', attrs={ 'class': 'featuredCity' } )[0] + ', ' + zone + plot = title + "\n(" + location + ')' + if plot == None: plot='' + if (DEBUG): logger.info("%s, %s, %s, %s, %s" % (title, thumbnail, url, location, plot)) + item=Item(action="play", title=title, url=url, thumbnail=thumbnail, + fanart=thumbnail, plot=plot ) + itemlist.append( item ) try: links = parseDOM( parseDOM( html, 'div', attrs={'id': 'pagination_bottom'} ), 'a', ret='href' ) @@ -129,7 +129,7 @@ def _get_category(item, category): category = 'search_results' else: url = URL + PREFIX_PATCH + url[1:] - logger.info(url) + if (DEBUG): (url) item=Item(action=category, title='Next >>' , url=url, thumbnail='', fanart='', plot='' ) itemlist.append( item ) @@ -140,17 +140,17 @@ def _get_category(item, category): def search_results(item): - logger.info("[channel.py] search_results") + if (DEBUG): ("[channel.py] search_results") return _get_category( item, 'search_results' ) def place(item): - logger.info("[channel.py] place") + if (DEBUG): ("[channel.py] place") return _get_category( item, 'place' ) def places(item): - logger.info("[channel.py] places") + if (DEBUG): ("[channel.py] places") itemlist = [] html = _get_html( item.url ) places = parseDOM( html, 'a', attrs={'class': 'locationLink'} ) @@ -166,12 +166,31 @@ def places(item): # featured cams def cams(item): - logger.info("[channel.py] cams") + if (DEBUG): ("[channel.py] cams") itemlist = [] if (DEBUG): logger.info("url=" + item.url) html = _get_html( item.url ) + divs = parseDOM( html, 'div', attrs={'class': r'[^\'"]*?col\-xs\-12' } ) + for _id, div in enumerate( divs ): + thumbnail = parseDOM( div, 'img', ret='src' )[0].replace('256x144', '512x288').replace('128x72', '256x144') + url = parseDOM( div, 'a', ret='href' )[0] + if 'www.earthcam.com' not in url or 'alexa' in url or 'myearthcam' in url: + continue + title = parseDOM( div, 'span', attrs={'class': 'featuredTitle'} )[0] + location = parseDOM( div, 'div', attrs={ 'class': 'featuredCity' } )[0] + plot = title + "\n(" + location + ')' + if plot == None: plot='' + if (DEBUG): logger.info("%s, %s, %s, %s, %s" % (title, thumbnail, url, location, plot)) + item=Item(action="play", title=title, url=url, thumbnail=thumbnail, + fanart=thumbnail, plot=plot ) + itemlist.append( item ) + + # more cameras from front page + if (DEBUG): logger.info("url=" + URL) + + html = _get_html( URL ) divs = parseDOM( html, 'div', attrs={ 'class': '[^\'"]*?camera_block[^\'"]*?' } ) for _id, div in enumerate(divs): @@ -232,7 +251,7 @@ def previous_play(item, just_check=False): itemlist.append( new_item ) return itemlist except Exception, e: - logger.info("[earthcam] channel.py " + str(e)) + if (DEBUG): ("[earthcam] channel.py " + str(e)) return [] if (DEBUG): logger.info("json_text="+json_text) if json_text.startswith('%'): diff --git a/core/scrapertools.py b/core/scrapertools.py index f631f4b..d22040d 100644 --- a/core/scrapertools.py +++ b/core/scrapertools.py @@ -35,7 +35,7 @@ def cache_page(url,post=None,headers=[['User-Agent', 'Mozilla/5.0 (Macintosh; U; # TODO: (3.1) Quitar el parámetro modoCache (ahora se hace por configuración) # TODO: (3.2) Usar notación minusculas_con_underscores para funciones y variables como recomienda Python http://www.python.org/dev/peps/pep-0008/ def cachePage(url,post=None,headers=[['User-Agent', 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; es-ES; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12']],modoCache=CACHE_ACTIVA, timeout=socket.getdefaulttimeout()): - url = urllib2.quote(url, safe='/:?=&') # :-o + url = urllib2.quote(url, safe='/:?=&%+') # :-o if (DEBUG==True): logger.info("[scrapertools.py] cachePage url="+url) modoCache = config.get_setting("cache.mode")