def imdb_user_list(self, url): try: result = client.request(url) result = result.decode('iso-8859-1').encode('utf-8') items = client.parseDOM(result, 'div', attrs = {'class': 'list_name'}) except: pass for item in items: try: name = client.parseDOM(item, 'a')[0] name = client.replaceHTMLCodes(name) name = name.encode('utf-8') url = client.parseDOM(item, 'a', ret='href')[0] url = url.split('/list/', 1)[-1].replace('/', '') url = self.imdblist_link % url url = client.replaceHTMLCodes(url) url = url.encode('utf-8') self.list.append({'name': name, 'url': url, 'context': url}) except: pass return self.list
def pierwsza_list(self, url): items = cache.get(pierwsza.chanels, 2) #items = pierwsza.chanels() next = '' for item in items: try: id = str(item['id']) id = id.encode('utf-8') title = item['name'] title = client.replaceHTMLCodes(title) title = title.encode('utf-8') poster = '0' try: poster = item['thumbail'] poster = self.pierwsza_link+poster except: pass poster = poster.encode('utf-8') fanart = '0' try: fanart = item['thumbail'] fanart = self.pierwsza_link+fanart except: pass fanart = fanart.encode('utf-8') plot = '0' try: plot = item['overview'] except: pass if plot == None: plot = '0' plot = client.replaceHTMLCodes(plot) plot = plot.encode('utf-8') try: tagline = item['tagline'] except: tagline = None if tagline == None and not plot == '0': tagline = re.compile('[.!?][\s]{1,2}(?=[A-Z])').split(plot)[0] elif tagline == None: tagline = '0' tagline = client.replaceHTMLCodes(tagline) try: tagline = tagline.encode('utf-8') except: pass self.list.append({'title': title, 'originaltitle': title, 'genre': '0', 'plot': plot, 'name':title, 'tagline': tagline, 'poster': poster, 'fanart': fanart, 'id':id, 'service':'pierwsza', 'next': next}) #control.log("##################><><><><> pierwsza item %s" % self.list) except: control.log("##################><><><><> pierwsza item %s" % newlist) pass import operator self.list.sort(key=operator.itemgetter('title')) return self.list
def trakt_user_list(self, url, user): try: result = trakt.getTrakt(url) items = json.loads(result) except: pass for item in items: try: try: name = item['list']['name'] except: name = item['name'] name = client.replaceHTMLCodes(name) name = name.encode('utf-8') try: url = (trakt.slug(item['list']['user']['username']), item['list']['ids']['slug']) except: url = ('me', item['ids']['slug']) url = self.traktlist_link % url url = url.encode('utf-8') self.list.append({'name': name, 'url': url, 'context': url}) except: pass self.list = sorted(self.list, key=lambda k: re.sub('(^the |^a )', '', k['name'].lower())) return self.list
def wizja_list(self, url): try: next = '' #items = cache.get(wizja.wizjachanels, 2) items = wizja.wizjachanels() for item in items: id = item['id'] title = item['title'] title = client.replaceHTMLCodes(title) poster = '0' try: poster = item['img'] except: pass poster = poster.encode('utf-8') try: fanart = control.addonFanart() except: fanart = '0' pass fanart = fanart.encode('utf-8') plot = '0' plot = client.replaceHTMLCodes(plot) plot = plot.encode('utf-8') tagline = None if tagline == None and not plot == '0': tagline = re.compile('[.!?][\s]{1,2}(?=[A-Z])').split(plot)[0] elif tagline == None: tagline = '0' tagline = client.replaceHTMLCodes(tagline) try: tagline = tagline.encode('utf-8') except: pass self.list.append({'title': title, 'originaltitle': title, 'genre': '0', 'plot': plot, 'name':title, 'tagline': tagline, 'poster': poster, 'fanart': fanart, 'id':id, 'service':'wizja', 'next': next}) #control.log("##################><><><><> pierwsza item %s" % self.list) import operator self.list.sort(key=operator.itemgetter('title')) return self.list except: pass
def wizja_list(self, url): try: next = '' items = cache.get(wizja.wizjachanels, 2) #items = wizja.wizjachanels() for item in items: id = item['id'] title = item['title'] title = client.replaceHTMLCodes(title) poster = '0' try: poster = item['img'] except: pass poster = poster.encode('utf-8') fanart = '0' try: fanart = item['img'] except: pass fanart = fanart.encode('utf-8') plot = '0' plot = client.replaceHTMLCodes(plot) plot = plot.encode('utf-8') tagline = None if tagline == None and not plot == '0': tagline = re.compile('[.!?][\s]{1,2}(?=[A-Z])').split(plot)[0] elif tagline == None: tagline = '0' tagline = client.replaceHTMLCodes(tagline) try: tagline = tagline.encode('utf-8') except: pass self.list.append({'title': title, 'originaltitle': title, 'genre': '0', 'plot': plot, 'name':title, 'tagline': tagline, 'poster': poster, 'fanart': fanart, 'id':id, 'service':'wizja', 'next': next}) #control.log("##################><><><><> pierwsza item %s" % self.list) import operator self.list.sort(key=operator.itemgetter('title')) return self.list except: pass
def weebchanels(): items = [] try: result = get('/api/getChannelList') result = json.loads(result) for i in result: try: if result[i]['channel_online'] != '2': raise Exception() id = result[i]['channel_name'] title = result[i]['channel_title'].encode('utf-8') poster = '0' try: poster = result[i]['channel_logo_url'] except: pass fanart = '0' try: fanart = result[i]['channel_logo_url'] except: pass #fanart = fanart.encode('utf-8') plot = '0' try: plot=result[i]['channel_description'] plot = client.replaceHTMLCodes(plot) except: pass #plot = plot.encode('utf-8') tagline = '0' try: tagline = tagline.encode('utf-8') except: pass #tagline = plot.encode('utf-8') #ala = {'name': title, 'id': id} ala={'title': title, 'originaltitle': title, 'genre': '0', 'plot': plot, 'name': title, 'tagline': tagline, 'poster': poster, 'fanart': fanart, 'id': id,'service':'weeb', 'next': ''} items.append(ala) except: pass if len(items) == 0: items = result except: control.log('Error weeb.chanels' ) pass return items
def predb_list(i): try: url = self.imdb_by_query % (urllib.quote_plus(i[0]), i[1]) item = client.request(url, timeout='10') item = json.loads(item) title = item['Title'] title = client.replaceHTMLCodes(title) title = title.encode('utf-8') year = item['Year'] year = re.sub('[^0-9]', '', str(year)) year = year.encode('utf-8') name = '%s (%s)' % (title, year) try: name = name.encode('utf-8') except: pass imdb = item['imdbID'] if imdb == None or imdb == '' or imdb == 'N/A': raise Exception() imdb = 'tt' + re.sub('[^0-9]', '', str(imdb)) imdb = imdb.encode('utf-8') poster = item['Poster'] if poster == None or poster == '' or poster == 'N/A': poster = '0' if not ('_SX' in poster or '_SY' in poster): poster = '0' poster = re.sub('_SX\d*|_SY\d*|_CR\d+?,\d+?,\d+?,\d*','_SX500', poster) poster = poster.encode('utf-8') genre = item['Genre'] if genre == None or genre == '' or genre == 'N/A': genre = '0' genre = genre.replace(', ', ' / ') genre = genre.encode('utf-8') duration = item['Runtime'] if duration == None or duration == '' or duration == 'N/A': duration = '0' duration = re.sub('[^0-9]', '', str(duration)) duration = duration.encode('utf-8') rating = item['imdbRating'] if rating == None or rating == '' or rating == 'N/A' or rating == '0.0': rating = '0' rating = rating.encode('utf-8') votes = item['imdbVotes'] try: votes = str(format(int(votes),',d')) except: pass if votes == None or votes == '' or votes == 'N/A': votes = '0' votes = votes.encode('utf-8') mpaa = item['Rated'] if mpaa == None or mpaa == '' or mpaa == 'N/A': mpaa = '0' mpaa = mpaa.encode('utf-8') director = item['Director'] if director == None or director == '' or director == 'N/A': director = '0' director = director.replace(', ', ' / ') director = re.sub(r'\(.*?\)', '', director) director = ' '.join(director.split()) director = director.encode('utf-8') writer = item['Writer'] if writer == None or writer == '' or writer == 'N/A': writer = '0' writer = writer.replace(', ', ' / ') writer = re.sub(r'\(.*?\)', '', writer) writer = ' '.join(writer.split()) writer = writer.encode('utf-8') cast = item['Actors'] if cast == None or cast == '' or cast == 'N/A': cast = '0' cast = [x.strip() for x in cast.split(',') if not x == ''] try: cast = [(x.encode('utf-8'), '') for x in cast] except: cast = [] if cast == []: cast = '0' plot = item['Plot'] if plot == None or plot == '' or plot == 'N/A': plot = '0' plot = client.replaceHTMLCodes(plot) plot = plot.encode('utf-8') tagline = re.compile('[.!?][\s]{1,2}(?=[A-Z])').split(plot)[0] try: tagline = tagline.encode('utf-8') except: pass self.list.append({'title': title, 'originaltitle': title, 'year': year, 'premiered': '0', 'studio': '0', 'genre': genre, 'duration': duration, 'rating': rating, 'votes': votes, 'mpaa': mpaa, 'director': director, 'writer': writer, 'cast': cast, 'plot': plot, 'tagline': tagline, 'name': name, 'code': imdb, 'imdb': imdb, 'tmdb': '0', 'tvdb': '0', 'tvrage': '0', 'poster': poster, 'banner': '0', 'fanart': '0'}) except: pass
def imdb_list(self, url, idx=True): try: if url == self.imdbwatchlist_link: def imdb_watchlist_id(url): return re.compile('/export[?]list_id=(ls\d*)').findall(client.request(url))[0] url = cache.get(imdb_watchlist_id, 8640, url) url = self.imdblist_link % url headers = {'Accept-Language': 'en-US'} result = str(client.request(url,headers=headers)) try: if idx == True: raise Exception() pages = client.parseDOM(result, 'div', attrs = {'class': 'desc'})[0] pages = re.compile('Page \d+? of (\d*)').findall(pages)[0] for i in range(1, int(pages)): u = url.replace('&start=1', '&start=%s' % str(i*100+1)) result += str(client.request(u)) except: pass result = result.replace('\n','') result = result.decode('iso-8859-1').encode('utf-8') items = client.parseDOM(result, 'tr', attrs = {'class': '.+?'}) items += client.parseDOM(result, 'div', attrs = {'class': 'list_item.+?'}) except: return try: next = client.parseDOM(result, 'span', attrs = {'class': 'pagination'}) next += client.parseDOM(result, 'div', attrs = {'class': 'pagination'}) name = client.parseDOM(next[-1], 'a')[-1] if 'laquo' in name: raise Exception() next = client.parseDOM(next, 'a', ret='href')[-1] next = url.replace(urlparse.urlparse(url).query, urlparse.urlparse(next).query) next = client.replaceHTMLCodes(next) next = next.encode('utf-8') except: next = '' for item in items: try: try: title = client.parseDOM(item, 'a')[1] except: pass try: title = client.parseDOM(item, 'a', attrs = {'onclick': '.+?'})[-1] except: pass title = client.replaceHTMLCodes(title) title = title.encode('utf-8') year = client.parseDOM(item, 'span', attrs = {'class': 'year_type'})[0] year = re.compile('(\d{4})').findall(year)[-1] year = year.encode('utf-8') if int(year) > int((self.datetime).strftime('%Y')): raise Exception() name = '%s (%s)' % (title, year) try: name = name.encode('utf-8') except: pass imdb = client.parseDOM(item, 'a', ret='href')[0] imdb = 'tt' + re.sub('[^0-9]', '', imdb.rsplit('tt', 1)[-1]) imdb = imdb.encode('utf-8') poster = '0' try: poster = client.parseDOM(item, 'img', ret='src')[0] except: pass try: poster = client.parseDOM(item, 'img', ret='loadlate')[0] except: pass if not ('_SX' in poster or '_SY' in poster): poster = '0' poster = re.sub('_SX\d*|_SY\d*|_CR\d+?,\d+?,\d+?,\d*','_SX500', poster) poster = client.replaceHTMLCodes(poster) poster = poster.encode('utf-8') genre = client.parseDOM(item, 'span', attrs = {'class': 'genre'}) genre = client.parseDOM(genre, 'a') genre = ' / '.join(genre) if genre == '': genre = '0' genre = client.replaceHTMLCodes(genre) genre = genre.encode('utf-8') try: duration = re.compile('(\d+?) mins').findall(item)[-1] except: duration = '0' duration = client.replaceHTMLCodes(duration) duration = duration.encode('utf-8') try: rating = client.parseDOM(item, 'span', attrs = {'class': 'rating-rating'})[0] except: rating = '0' try: rating = client.parseDOM(rating, 'span', attrs = {'class': 'value'})[0] except: rating = '0' if rating == '' or rating == '-': rating = '0' rating = client.replaceHTMLCodes(rating) rating = rating.encode('utf-8') try: votes = client.parseDOM(item, 'div', ret='title', attrs = {'class': 'rating rating-list'})[0] except: votes = '0' try: votes = re.compile('[(](.+?) votes[)]').findall(votes)[0] except: votes = '0' if votes == '': votes = '0' votes = client.replaceHTMLCodes(votes) votes = votes.encode('utf-8') try: mpaa = client.parseDOM(item, 'span', attrs = {'class': 'certificate'})[0] except: mpaa = '0' try: mpaa = client.parseDOM(mpaa, 'span', ret='title')[0] except: mpaa = '0' if mpaa == '' or mpaa == 'NOT_RATED': mpaa = '0' mpaa = mpaa.replace('_', '-') mpaa = client.replaceHTMLCodes(mpaa) mpaa = mpaa.encode('utf-8') director = client.parseDOM(item, 'span', attrs = {'class': 'credit'}) director += client.parseDOM(item, 'div', attrs = {'class': 'secondary'}) try: director = [i for i in director if 'Director:' in i or 'Dir:' in i][0] except: director = '0' director = director.split('With:', 1)[0].strip() director = client.parseDOM(director, 'a') director = ' / '.join(director) if director == '': director = '0' director = client.replaceHTMLCodes(director) director = director.encode('utf-8') cast = client.parseDOM(item, 'span', attrs = {'class': 'credit'}) cast += client.parseDOM(item, 'div', attrs = {'class': 'secondary'}) try: cast = [i for i in cast if 'With:' in i or 'Stars:' in i][0] except: cast = '0' cast = cast.split('With:', 1)[-1].strip() cast = client.replaceHTMLCodes(cast) cast = cast.encode('utf-8') cast = client.parseDOM(cast, 'a') if cast == []: cast = '0' plot = '0' try: plot = client.parseDOM(item, 'span', attrs = {'class': 'outline'})[0] except: pass try: plot = client.parseDOM(item, 'div', attrs = {'class': 'item_description'})[0] except: pass plot = plot.rsplit('<span>', 1)[0].strip() if plot == '': plot = '0' plot = client.replaceHTMLCodes(plot) plot = plot.encode('utf-8') fanart = 'http://films4u.org/imdb/bgs/'+imdb+'.jpg' fanart = fanart.encode('utf-8') tagline = re.compile('[.!?][\s]{1,2}(?=[A-Z])').split(plot)[0] try: tagline = tagline.encode('utf-8') except: pass self.list.append({'title': title, 'originaltitle': title, 'year': year, 'premiered': '0', 'studio': '0', 'genre': genre, 'duration': duration, 'rating': rating, 'votes': votes, 'mpaa': mpaa, 'director': director, 'writer': '0', 'cast': cast, 'plot': plot, 'tagline': tagline, 'name': name, 'code': imdb, 'imdb': imdb, 'tmdb': '0', 'tvdb': '0', 'tvrage': '0', 'poster': poster, 'banner': '0', 'fanart': fanart, 'next': next}) except: pass return self.list
def trakt_list(self, url, user): #control.log('### TRAKT LISTS') try: q = dict(urlparse.parse_qsl(urlparse.urlsplit(url).query)) q.update({'extended': 'full,images'}) q = (urllib.urlencode(q)).replace('%2C', ',') u = url.replace('?' + urlparse.urlparse(url).query, '') + '?' + q result = trakt.getTrakt(u) result = json.loads(result) items = [] for i in result: try: items.append(i['movie']) except: pass if len(items) == 0: items = result except: return try: q = dict(urlparse.parse_qsl(urlparse.urlsplit(url).query)) p = str(int(q['page']) + 1) if p == '5': raise Exception() q.update({'page': p}) q = (urllib.urlencode(q)).replace('%2C', ',') next = url.replace('?' + urlparse.urlparse(url).query, '') + '?' + q next = next.encode('utf-8') except: next = '' for item in items: try: title = item['name'] title = client.replaceHTMLCodes(title) title = title.encode('utf-8') poster = '0' try: poster = item['thumbail'] except: pass poster = poster.encode('utf-8') fanart = '0' try: fanart = item['thumbail'] except: pass fanart = fanart.encode('utf-8') plot = '0' try: plot = item['overview'] except: pass if plot == None: plot = '0' plot = client.replaceHTMLCodes(plot) plot = plot.encode('utf-8') try: tagline = item['tagline'] except: tagline = None if tagline == None and not plot == '0': tagline = re.compile('[.!?][\s]{1,2}(?=[A-Z])').split(plot)[0] elif tagline == None: tagline = '0' tagline = client.replaceHTMLCodes(tagline) try: tagline = tagline.encode('utf-8') except: pass self.list.append({'title': title, 'originaltitle': title, 'genre': '0', 'plot': plot, 'tagline': tagline, 'name': name, 'poster': poster, 'fanart': fanart, 'next': next}) except: pass return self.list
def videostar_list(self, url): items = [] try: result = videostar.get('/channels/list/ios-plus') result = json.loads(result) for i in result['channels']: #control.log('Result %s' % i) if i['access_status']== 'subscribed': try: items.append(i) except: pass if len(items) == 0: items = result except Exception as e: control.log('Error tv.get %s' % e) next = '' for item in items: control.log('Result %s' % item) try: id = str(item['id']) id = id.encode('utf-8') title = item['name'] title = client.replaceHTMLCodes(title) title = title.encode('utf-8') poster = '0' try: poster = item['thumbnail'] except: pass poster = poster.encode('utf-8') fanart = '0' try: fanart = item['thumbnail'] except: pass fanart = fanart.encode('utf-8') plot = '0' try: plot = item['overview'] except: pass if plot == None: plot = '0' plot = client.replaceHTMLCodes(plot) plot = plot.encode('utf-8') try: tagline = item['tagline'] except: tagline = None if tagline == None and not plot == '0': tagline = re.compile('[.!?][\s]{1,2}(?=[A-Z])').split(plot)[0] elif tagline == None: tagline = '0' tagline = client.replaceHTMLCodes(tagline) try: tagline = tagline.encode('utf-8') except: pass self.list.append({'title': title, 'originaltitle': title, 'genre': '0', 'plot': plot, 'name':title, 'tagline': tagline, 'poster': poster, 'fanart': fanart, 'id':id, 'service':'videostar', 'next': next}) #control.log("##################><><><><> pierwsza item %s" % self.list) except Exception as e: control.log('Error tv.get2 %s' % e) pass #self.list.sort() import operator self.list.sort(key=operator.itemgetter('title')) #control.log("##################><><><><> pierwsza item %s" % newlist) return self.list
li.setArt({'fanart': control.addonFanart2()}) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) xbmcplugin.endOfDirectory(addon_handle) elif mode[0] == 'tv': list = [] try: items = wizja.wizjachanels() for item in items: id = item['id'] title = item['title'] title = client.replaceHTMLCodes(title) poster = '0' try: poster = item['img'] except: pass poster = poster.encode('utf-8') try: fanart = control.addonFanart() fanart = fanart.encode('utf-8') except: fanart = '0' fanart = fanart.encode('utf-8') pass
url = build_url({'mode': 'ustawienia', 'foldername': 'Ustawienia'}) li = xbmcgui.ListItem('Ustawienia', iconImage=icon) li.setArt({'fanart': control.addonFanart2()}) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) xbmcplugin.endOfDirectory(addon_handle) elif mode[0] == 'tv': list = [] try: items = wizja.wizjachanels() for item in items: id = item['id'] title = item['title'] title = client.replaceHTMLCodes(title) poster = '0' try: poster = item['img'] except: pass poster = poster.encode('utf-8') try: fanart = control.addonFanart() fanart = fanart.encode('utf-8') except: fanart = '0' fanart = fanart.encode('utf-8') pass plot = '0'
def weebchanels(): items = [] try: result = get('/api/getChannelList') result = json.loads(result) for i in result: try: if result[i]['channel_online'] != '2': raise Exception() id = result[i]['channel_name'] title = result[i]['channel_title'].encode('utf-8') poster = '0' try: poster = result[i]['channel_logo_url'] except: pass fanart = '0' try: fanart = result[i]['channel_logo_url'] except: pass #fanart = fanart.encode('utf-8') plot = '0' try: plot = result[i]['channel_description'] plot = client.replaceHTMLCodes(plot) except: pass #plot = plot.encode('utf-8') tagline = '0' try: tagline = tagline.encode('utf-8') except: pass #tagline = plot.encode('utf-8') #ala = {'name': title, 'id': id} ala = { 'title': title, 'originaltitle': title, 'genre': '0', 'plot': plot, 'name': title, 'tagline': tagline, 'poster': poster, 'fanart': fanart, 'id': id, 'service': 'weeb', 'next': '' } items.append(ala) except: pass if len(items) == 0: items = result except: control.log('Error weeb.chanels') pass return items