# -*- coding: utf-8 -*- #------------------------------------------------------------ import urlparse,urllib2,urllib,re import os, sys from platformcode import config, logger from core import scrapertools from core.item import Item from core import servertools from core import httptools host = 'https://www.shameless.com' def mainlist(item): logger.info() itemlist = [] itemlist.append( Item(channel=item.channel, title="Nuevos" , action="lista", url=host + "/videos/1/")) itemlist.append( Item(channel=item.channel, title="Mas popular" , action="lista", url=host + "/videos/popular/week/")) itemlist.append( Item(channel=item.channel, title="Mejor valorada" , action="lista", url=host + "/videos/rated/week/")) itemlist.append( Item(channel=item.channel, title="Categorias" , action="categorias", url=host + "/categories/")) itemlist.append( Item(channel=item.channel, title="Buscar", action="search")) return itemlist def search(item, texto): logger.info() texto = texto.replace(" ", "+") item.url = host + "/search/?q=%s" % texto try: return lista(item) except: import sys for line in sys.exc_info(): logger.error("%s" % line) return [] def categorias(item): logger.info() itemlist = [] data = httptools.downloadpage(item.url).data data = re.sub(r"\n|\r|\t| |
|
", "", data) patron = '|
", "", data) patron = '
.*?", "", data) patron = '(?:video_url|video_alt_url[0-9]*):\s*\'([^\']+)\'.*?' patron += '(?:video_url_text|video_alt_url[0-9]*_text):\s*\'([^\']+)\'' matches = scrapertools.find_multiple_matches(data, patron) for url, quality in matches: headers = {'Referer': item.url} url = httptools.downloadpage(url, headers=headers , follow_redirects=False, only_headers=True).headers.get("location", "") itemlist.append(["%s %s [directo]" % (quality, url), url]) return itemlist