from de.generia.kodi.plugin.backend.web.HtmlResource import HtmlResource from de.generia.kodi.plugin.backend.zdf import stripHtml from de.generia.kodi.plugin.backend.zdf.Regex import getTagPattern from de.generia.kodi.plugin.backend.zdf.Regex import getTag from de.generia.kodi.plugin.backend.zdf.Regex import compile leftNavPattern = getTagPattern('ul', 'left-nav') dropdownLinksPattern = compile( '<a\s*class="[^"]*dropdown-link[^"]*"[^>]*href="([^"]*)"[^>]*data-title="([^"]*)"' ) class Rubric(object): def __init__(self, title, url): self.title = title self.url = url def __str__(self): return "<Rubric '%s' url='%s'>" % (self.title, self.url) class NavigationResource(HtmlResource): def __init__(self, url): super(NavigationResource, self).__init__(url) def parse(self): super(NavigationResource, self).parse() leftNavMatch = leftNavPattern.search(self.content) if leftNavMatch is None: self.warn(
from de.generia.kodi.plugin.backend.web.HtmlResource import HtmlResource from de.generia.kodi.plugin.backend.zdf.Regex import compile from de.generia.kodi.plugin.backend.zdf.Teaser import Teaser resultsPattern = compile('<div\s*class="[^"]*"\s*data-loadmore-size="([^"]*)"\s*data-loadmore-result-count="([^"]*)"\s*data-module="loadmore">') loadMorePattern = compile('<a\s*href="([^"]*)"[^>]*class="[^"]*load-more[^"]*"') class SearchResource(HtmlResource): def __init__(self, url): super(SearchResource, self).__init__(url) def parse(self): super(SearchResource, self).parse() self.teasers = [] self.resultsPerPage = 0 self.results = 0 pos = 0 resultsMatch = resultsPattern.search(self.content, pos) if resultsMatch is not None: loadMoreSize = resultsMatch.group(1) if loadMoreSize is not None and loadMoreSize != '': self.resultsPerPage = int(loadMoreSize) loadMoreCount = resultsMatch.group(2) if loadMoreCount is None or loadMoreCount == '': return; self.results = int(loadMoreCount) pos = resultsMatch.end(0)
from de.generia.kodi.plugin.backend.zdf.AbstractPageResource import AbstractPageResource from de.generia.kodi.plugin.backend.zdf import stripHtml from de.generia.kodi.plugin.backend.zdf.Regex import getTagPattern from de.generia.kodi.plugin.backend.zdf.Regex import getTag from de.generia.kodi.plugin.backend.zdf.Regex import compile from de.generia.kodi.plugin.backend.zdf.Regex import stripTag from de.generia.kodi.plugin.backend.zdf.Teaser import Teaser from de.generia.kodi.plugin.backend.zdf.TeaserLazyload import TeaserLazyload from urlparse import urlparse fallbackTitlePattern = compile( '<li\s*class="item current"[^>]*>[^<]*<a[^>]*>([^<]*)</a>') fallbackTitlePattern2 = compile( '<h\d\s*class="[^"]*stage-title[^"]*"[^>]*>([^<]*)</h\d>') moduleItemPattern = getTagPattern('div', 'item-caption') moduleItemTextPattern = compile( 'class="item-description"[^>]*>([^<]*)</?[^>]*>') moduleItemDatePattern = compile('<time[^>]*>([^<]*)</time>') moduleItemImagePattern = compile( 'class="item-img[^"]*"[^>]*data-srcset="([^"]*)"') moduleItemVideoPattern = compile('"1280x720":"([^\?]*)\?cb') postContentPattern = getTagPattern('div', 'details') stageTeaserPattern = getTagPattern('div', 'title-table') stageTeaserTextPattern = compile('class="teaser-text"[^>]*>([^<]*)</?[^>]*>')
from de.generia.kodi.plugin.backend.zdf.AbstractPageResource import AbstractPageResource from de.generia.kodi.plugin.backend.zdf import stripHtml from de.generia.kodi.plugin.backend.zdf.Regex import getTagPattern from de.generia.kodi.plugin.backend.zdf.Regex import getTag from de.generia.kodi.plugin.backend.zdf.Regex import compile from de.generia.kodi.plugin.backend.zdf.Teaser import Teaser livetvCellPattern = getTagPattern('div', 'js-livetv-scroller-cell') titlePattern = compile('<h2[^>]*>([^<]*)</h2>') contentNamePattern = compile('"embed_content"\s*:\s*"([^"]*)"') imagePattern = compile('data-src="([^"]*)"') class LiveTvResource(AbstractPageResource): def __init__(self, url): super(LiveTvResource, self).__init__(url) def parse(self): super(LiveTvResource, self).parse() livetvCellMatch = livetvCellPattern.search(self.content) if livetvCellMatch is None: #self.warn("can't find live-tv cells in page '{}', no channels will be available ...", self.url) return self.teasers = [] while livetvCellMatch is not None: pos = livetvCellMatch.end(0) teaser = Teaser() pos = self._parseTitle(pos, teaser) pos = self._parseContentName(pos, teaser)
from sets import Set from de.generia.kodi.plugin.backend.web.HtmlResource import HtmlResource from de.generia.kodi.plugin.backend.zdf import stripHtml from de.generia.kodi.plugin.backend.zdf.Regex import getTagPattern from de.generia.kodi.plugin.backend.zdf.Regex import getTag from de.generia.kodi.plugin.backend.zdf.Regex import compile leftNavPattern = getTagPattern('ul', 'left-nav') dropdownLinksPattern = compile('<a\s*class="[^"]*dropdown-link[^"]*"[^>]*href="([^"]*)"[^>]*data-title="([^"]*)"') class Rubric(object): def __init__(self, title, url): self.title = title self.url = url def __str__(self): return "<Rubric '%s' url='%s'>" % (self.title, self.url) class NavigationResource(HtmlResource): def __init__(self, url): super(NavigationResource, self).__init__(url) def parse(self): super(NavigationResource, self).parse() leftNavMatch = leftNavPattern.search(self.content) if leftNavMatch is None: self.warn("can't find navigation in page '{}', no rubrics will be available ...", self.url)
from de.generia.kodi.plugin.backend.web.HtmlResource import HtmlResource from de.generia.kodi.plugin.backend.zdf import stripHtml from de.generia.kodi.plugin.backend.zdf.Regex import getTagPattern from de.generia.kodi.plugin.backend.zdf.Regex import getTag from de.generia.kodi.plugin.backend.zdf.Regex import compile from de.generia.kodi.plugin.backend.zdf.Teaser import Teaser fallbackTitlePattern = compile( '<li\s*class="item current"[^>]*>[^<]*<a[^>]*>([^<]*)</a>') moduleItemPattern = getTagPattern('div', 'item-caption') moduleItemTextPattern = compile('class="item-description"[^>]*>([^<]*)<span') moduleItemDatePattern = compile('<time[^>]*>([^<]*)</time>') listPattern = compile( 'class="([^"]*b-cluster|[^"]*b-cluster [^"]*|[^"]*b-content-teaser-list[^"]*|[^"]*b-content-module[^"]*)"[^>]*>' ) sectionTitlePattern = compile( '<h2\s*class="[^"]*title[^"]*"[^>]*>([^<]*)</h2>') sectionItemPattern = getTagPattern('article', 'b-content-teaser-item') clusterTitlePattern = compile( '<h2\s*class="[^"]*cluster-title[^"]*"[^>]*>([^<]*)</h2>') clusterItemPattern = getTagPattern('article', 'b-cluster-teaser') class Cluster(object): def __init__(self, title, listType, listStart, listEnd=-1):
from datetime import datetime from de.generia.kodi.plugin.backend.zdf import stripHtml from de.generia.kodi.plugin.backend.zdf.Regex import getTagPattern from de.generia.kodi.plugin.backend.zdf.Regex import getTag from de.generia.kodi.plugin.backend.zdf.Regex import stripTag from de.generia.kodi.plugin.backend.zdf.Regex import cleanTags from de.generia.kodi.plugin.backend.zdf.Regex import compile teaserPattern = getTagPattern('article', 'b-content-teaser-item') sourcePattern = compile('class="m-16-9"[^>]*data-srcset="([^"]*)"') labelPattern = getTagPattern('div', 'teaser-label') iconPattern = compile('class="icon-[0-9]*_([^ ]*) icon">') catPattern = compile('class="teaser-cat"[^>]*>([^<]*)</[^>]*>') aPattern = compile('href="([^"]*)"[^>]*>') titleIconPattern = compile('class="title-icon icon-[0-9]*_([^"]*)">') textPattern = compile('class="teaser-text"[^>]*>([^<]*)</[^>]*>') datePattern = compile('class="video-airing"[^>]*>([^<]*)</[^>]*>') def compareTeasers(t1, t2): if t1 is None and t2 is None: return 0 if t1 is None and t2 is not None: return 1 if t1 is not None and t2 is None: return -1 ''' if t1.date is not None and t2.date is not None: d1 = datetime.strptime(t1.date, "%d.%m.%Y")
from datetime import datetime from de.generia.kodi.plugin.backend.zdf import stripHtml from de.generia.kodi.plugin.backend.zdf.Regex import getTagPattern from de.generia.kodi.plugin.backend.zdf.Regex import getTag from de.generia.kodi.plugin.backend.zdf.Regex import stripTag from de.generia.kodi.plugin.backend.zdf.Regex import cleanTags from de.generia.kodi.plugin.backend.zdf.Regex import compile teaserPattern = getTagPattern('article', 'b-content-teaser-item') sourcePattern = compile('class="m-16-9"[^>]*data-srcset="([^"]*)"') labelPattern = getTagPattern('div', 'teaser-label') iconPattern = compile('class="icon-[0-9]*_([^ ]*) icon">') catPattern = compile('class="teaser-cat\s*[^"]*"[^>]*>') catCategoryPattern = compile( 'class="teaser-cat-category\s*[^"]*"[^>]*>([^<]*)</[^>]*>') catBrandPattern = compile( 'class="teaser-cat-brand\s*[^"]*"[^>]*>([^<]*)</[^>]*>') aPattern = compile('href="([^"]*)"[^>]*>') textPattern = compile('class="teaser-text"[^>]*>([^<]*)</[^>]*>') footPattern = compile('class="teaser-foot\s*[^"]*"[^>]*>') footIconPattern = compile('class="[^"]*icon-[0-9]*_(play)[^"]*">') teaserInfoPattern = getTagPattern('dd', 'teaser-info') teaserInfoIsTiviPattern = getTagPattern('span', 'is-tivi') teaserInfoDurationPattern = compile('(.*) min') teaserInfoEpisodePattern = compile('S(..) F(..)') apiTokenPattern = compile('"apiToken"\s*:\s*"([^"]*)"') def compareTeasers(t1, t2): if t1 is None and t2 is None:
from de.generia.kodi.plugin.backend.web.HtmlResource import HtmlResource from de.generia.kodi.plugin.backend.zdf.Regex import compile apiTokenPattern = compile('<head>.*window.zdfsite\s*=\s*{.*apiToken:\s*\'([^\']*)\'.*</head>') class AbstractPageResource(HtmlResource): def __init__(self, url): super(AbstractPageResource, self).__init__(url) def parse(self): super(AbstractPageResource, self).parse() self.configApiToken = None pos = 0 apiTokenMatch = apiTokenPattern.search(self.content, pos) if apiTokenMatch is not None: self.configApiToken = apiTokenMatch.group(1) pos = apiTokenMatch.end(0) self.content = self.content[pos:len(self.content)]
from de.generia.kodi.plugin.backend.web.HtmlResource import HtmlResource from de.generia.kodi.plugin.backend.zdf import stripHtml from de.generia.kodi.plugin.backend.zdf.Regex import getTagPattern from de.generia.kodi.plugin.backend.zdf.Regex import getTag from de.generia.kodi.plugin.backend.zdf.Regex import compile from de.generia.kodi.plugin.backend.zdf.Teaser import Teaser livetvCellPattern = getTagPattern('div', 'js-livetv-scroller-cell') titlePattern = compile('<h2[^>]*>([^<]*)</h2>') contentNamePattern = compile('data-zdfplayer-id="([^"]*)"') imagePattern = compile('data-src="([^"]*)"') class LiveTvResource(HtmlResource): def __init__(self, url): super(LiveTvResource, self).__init__(url) def parse(self): super(LiveTvResource, self).parse() livetvCellMatch = livetvCellPattern.search(self.content) if livetvCellMatch is None: #self.warn("can't find live-tv cells in page '{}', no channels will be available ...", self.url) return self.teasers = [] while livetvCellMatch is not None: pos = livetvCellMatch.end(0) teaser = Teaser() pos = self._parseTitle(pos, teaser)
from de.generia.kodi.plugin.backend.web.HtmlResource import HtmlResource from de.generia.kodi.plugin.backend.zdf import stripHtml from de.generia.kodi.plugin.backend.zdf.Regex import getTagPattern from de.generia.kodi.plugin.backend.zdf.Regex import getTag from de.generia.kodi.plugin.backend.zdf.Regex import compile from de.generia.kodi.plugin.backend.zdf.Teaser import Teaser fallbackTitlePattern = compile('<li\s*class="item current"[^>]*>[^<]*<a[^>]*>([^<]*)</a>') fallbackTitlePattern2 = compile('<h\d\s*class="[^"]*stage-title[^"]*"[^>]*>([^<]*)</h\d>') moduleItemPattern = getTagPattern('div', 'item-caption') moduleItemTextPattern = compile('class="item-description"[^>]*>([^<]*)<span') moduleItemDatePattern = compile('<time[^>]*>([^<]*)</time>') listPattern = compile('class="([^"]*b-cluster|[^"]*b-cluster [^"]*|[^"]*b-content-teaser-list[^"]*|[^"]*b-content-module[^"]*)"[^>]*>') sectionTitlePattern = compile('<h2\s*class="[^"]*title[^"]*"[^>]*>([^<]*)</h2>') sectionItemPattern = getTagPattern('article', 'b-content-teaser-item') clusterTitlePattern = compile('<h2\s*class="[^"]*cluster-title[^"]*"[^>]*>([^<]*)</h2>') clusterItemPattern = getTagPattern('article', 'b-cluster-teaser') class Cluster(object): def __init__(self, title, listType, listStart, listEnd=-1): self.title = title self.listType = listType self.listStart = listStart self.listEnd = listEnd
from datetime import datetime from de.generia.kodi.plugin.backend.zdf import stripHtml from de.generia.kodi.plugin.backend.zdf.Regex import getTagPattern from de.generia.kodi.plugin.backend.zdf.Regex import getTag from de.generia.kodi.plugin.backend.zdf.Regex import stripTag from de.generia.kodi.plugin.backend.zdf.Regex import compile teaserPattern = getTagPattern('article', 'b-content-teaser-item') sourcePattern = compile('class="m-16-9"[^>]*data-srcset="([^"]*)"') labelPattern = getTagPattern('div', 'teaser-label') iconPattern = compile('class="icon-[0-9]*_([^ ]*) icon">') catPattern = compile('class="teaser-cat"[^>]*>([^<]*)</[^>]*>') aPattern = compile('href="([^"]*)"[^>]*>') titleIconPattern = compile('class="title-icon icon-[0-9]*_([^"]*)">') textPattern = compile('class="teaser-text"[^>]*>([^<]*)</[^>]*>') datePattern = compile('class="video-airing"[^>]*>([^<]*)</[^>]*>') def compareTeasers(t1, t2): if t1 is None and t2 is None: return 0 if t1 is None and t2 is not None: return 1 if t1 is not None and t2 is None: return -1 ''' if t1.date is not None and t2.date is not None: d1 = datetime.strptime(t1.date, "%d.%m.%Y") d2 = datetime.strptime(t2.date, "%d.%m.%Y") return d1.toordinal() - d2.toordinal()
from de.generia.kodi.plugin.backend.web.Resource import Resource from de.generia.kodi.plugin.backend.zdf.Regex import compile bandwidthPattern = compile('BANDWIDTH=([^,]*),') class PlaylistResource(Resource): def __init__(self, url, accept='application/vnd.apple.mpegurl'): super(PlaylistResource, self).__init__(url, accept) self.playlist = None def getPlaylist(self): return self.playlist def parse(self): super(PlaylistResource, self).parse() lines = self.content.split("\n") programMap = self._parseProgramMap(lines) maxBandwith = self._getMaxBandwidth(programMap) if maxBandwith is None: return filteredLines = self._filterPlaylist(lines, maxBandwith, programMap) self.playlist = "\n".join(filteredLines) def _parseProgramMap(self, lines): bandwith = None programMap = dict() for line in lines: line = line.strip() if line.startswith("#"):
from de.generia.kodi.plugin.backend.web.HtmlResource import HtmlResource from de.generia.kodi.plugin.backend.zdf import stripHtml from de.generia.kodi.plugin.backend.zdf.Regex import getTagPattern from de.generia.kodi.plugin.backend.zdf.Regex import getTag from de.generia.kodi.plugin.backend.zdf.Regex import compile from de.generia.kodi.plugin.backend.zdf.Teaser import Teaser livetvCellPattern = getTagPattern('div', 'js-livetv-scroller-cell') titlePattern = compile('<h2[^>]*>([^<]*)</h2>') contentNamePattern = compile('data-zdfplayer-id="([^"]*)"') imagePattern = compile('data-src="([^"]*)"') class LiveTvResource(HtmlResource): def __init__(self, url): super(LiveTvResource, self).__init__(url) def parse(self): super(LiveTvResource, self).parse() livetvCellMatch = livetvCellPattern.search(self.content) if livetvCellMatch is None: #self.warn("can't find live-tv cells in page '{}', no channels will be available ...", self.url) return self.teasers = [] while livetvCellMatch is not None: pos = livetvCellMatch.end(0) teaser = Teaser() pos = self._parseTitle(pos, teaser) pos = self._parseContentName(pos, teaser)