def to_items(url): #34 data = client.request(url, headers=headers) posts = zip(client.parseDOM(data, 'div', attrs={'id': r'post-\d+'}), client.parseDOM(data, 'h2')) for post, name in posts: try: plot = client.parseDOM(post, 'div', attrs={'class': 'plot'})[0] except IndexError: plot = 'N/A' desc = client.replaceHTMLCodes(plot) desc = tools.clear_Title(desc) desc = desc.encode('utf-8') try: title = client.parseDOM(name, 'a')[0] except BaseException: title = client.parseDOM(name, 'img', ret='alt')[0] # try: # year = client.parseDOM(data, 'div', {'class': 'metadata'})[0] # year = client.parseDOM(year, 'span')[0] # year = '[COLOR lime]({0})[/COLOR]'.format(year) # except IndexError: # year = '(N/A)' title = tools.clear_Title(title) title = '[B][COLOR white]{}[/COLOR][/B]'.format(title).encode('utf-8') link = client.parseDOM(name, 'a', ret='href')[0] link = client.replaceHTMLCodes(link).encode('utf-8', 'ignore') poster = client.parseDOM(post, 'img', ret='src')[0] poster = client.replaceHTMLCodes(poster).encode('utf-8', 'ignore') # if '/tvshows/' in link: # addon.add_directory({'mode': 'to_seasons', 'url': link}, {'title': title, 'plot': str(desc)}, # allfun, img=poster, fanart=FANART) # else: addon.add_directory({ 'mode': 'to_links', 'url': link }, { 'title': title, 'plot': str(desc) }, allfun, img=poster, fanart=FANART) try: np = client.parseDOM(data, 'a', ret='href', attrs={'rel': 'next'})[0] # np = dom_parser.parse_dom(np, 'a', req='href') # np = [i.attrs['href'] for i in np if 'icon-chevron-right' in i.content][0] page = re.findall(r'page/(\d+)/', np)[0] title = control.lang(32010).encode('utf-8') + \ ' [COLORwhite]([COLORlime]{}[/COLOR])[/COLOR]'.format(page) addon.add_directory({ 'mode': 'to_items', 'url': np }, {'title': title}, img=ART + 'next_page.png', fanart=FANART) except BaseException: pass control.content(int(sys.argv[1]), 'movies') control.directory(int(sys.argv[1])) view.setView('movies', {'skin.estuary': 55, 'skin.confluence': 500})
def genre(section): sec = 'category/films' if 'mov' in section else 'category/tv' html = client.request(Baseurl, headers=headers) items = client.parseDOM(html, 'ul', attrs={'class': 'categories'})[0] # xbmc.log('SCNSRC-GENRE2: {}'.format(str(items))) pattern = r'''<a href=(.+?)>(.+?)</a> <a.+?</.+?\((.+?)\)''' items = re.findall(pattern, items, re.DOTALL) # xbmc.log('SCNSRC-GENRE2: {}'.format(str(items))) items = [(i[0], i[1], i[2]) for i in items if sec in i[0]] for i in items: if 'tv-pack' in i[0]: continue title = i[1] title = tools.clear_Title(title) title = '{} ([COLORyellow]{}[/COLOR])'.format(title, str( i[2])).encode('utf-8') url = i[0].split(' ')[0] addon.add_directory({ 'mode': 'scn_items', 'url': url }, { 'title': title, 'plot': title }, allfun, img=ICON, fanart=FANART) control.content(int(sys.argv[1]), 'addons') control.directory(int(sys.argv[1])) view.setView('addons', {'skin.estuary': 55, 'skin.confluence': 500})
def genre(section): sec = 0 if 'mov' in section else 1 html = client.request(Baseurl, headers=headers) items = client.parseDOM(html, 'li', attrs={'class': 'category-list-item'})[sec] items = dom.parse_dom(items, 'a', req='href') for i in items: if 'tv-pack' in i[0]: continue title = i.content title = tools.clear_Title(title) title = '{}'.format(title).encode('utf-8') url = i.attrs['href'] addon.add_directory({ 'mode': 'ddl_items', 'url': url }, { 'title': title, 'plot': title }, allfun, img=ICON, fanart=FANART) control.content(int(sys.argv[1]), 'addons') control.directory(int(sys.argv[1])) view.setView('addons', {'skin.estuary': 55, 'skin.confluence': 500})