예제 #1
0
def reset_db():
	from dudehere.routines.plugin import Plugin
	plugin = Plugin()
	c = plugin.confirm("Reset Database", "Are you sure?", "You will have to restart kodi afterwards.")
	if c:
		DB_FILE = ADDON.get_setting('database_sqlite_file')
		ADDON.set_setting("database_sqlite_init", "false")
		vfs.rm(DB_FILE, quiet=True)
	def __init__(self, token="", quiet=False):
		self.quiet = quiet
		#self.token = token
		if ADDON.get_setting('trakt_oauth_token') == '':
			from dudehere.routines.plugin import Plugin
			plugin = Plugin()
			pin = plugin.dialog_input('Enter pin from %s' % PIN_URL)
			response = self._authorize(pin)
		else:
			self._authorize()
예제 #3
0
def select_host():
	from dudehere.routines.plugin import Plugin
	plugin = Plugin()
	hosts_file = vfs.join(DATA_PATH, "hosts.json")
	if vfs.exists(hosts_file):
		history = vfs.read_file(hosts_file, json=True)
		hosts = ["http://%s:%s" % (h['host'], h['port']) for h in history]
		host = plugin.dialog_select('Select a Host', hosts)
		if host is not False:
			host = history[host]
			ADDON.set_setting('remote_host', host['host'])
			ADDON.set_setting('remote_control_port', host['port'])
			ADDON.set_setting('remote_auth_pin', host['pin'])
	else:
		plugin.notify("Error", "Host history is empty")
예제 #4
0
	def raise_error(self, code, title, message):
		if code in [500, 502, 503, 504, 520, 521, 522, 524]:
			message = "Temporary " + message
		from dudehere.routines.plugin import Plugin
		image = vfs.join(ARTWORK, 'trakt_error.png')
		if vfs.exists(image) is False:
			image = vfs.join(ROOT_PATH, 'icon.png')
		Plugin().error_message(title, message, image=image)
예제 #5
0
 def raise_error(self, code, title, message):
     from dudehere.routines.plugin import Plugin
     from dudehere.routines.vfs import VFSClass
     image = VFSClass().join(ROOT_PATH, 'icon.png')
     Plugin().error_message(title, message, image=image)
예제 #6
0
 def clean_queue(self):
     from dudehere.routines.plugin import Plugin
     ok = Plugin().confirm("Clean Queue", "Remove complete and failed?")
     if ok: self._call("clear_queue")
     return ok
예제 #7
0
 def search_movies(self,
                   title,
                   year,
                   imdb_id=None,
                   tmdb_id=None,
                   return_sources=False):
     self._start_time = time.time()
     DB.connect()
     self.hashid = hashlib.md5(title + str(year)).hexdigest()
     last_hash_id = Plugin().get_property('last_hash_id')
     if self.hashid == last_hash_id:
         self.skip_autoplay = True
     else:
         self.skip_autoplay = False
         Plugin().set_property('last_hash_id', self.hashid)
     if self.cache_results:
         self.processor = Thread(target=self.process_queue)
         self.processor.start()
     self._get_active_resolvers()
     args = {
         "title": title,
         "year": year,
         "domains": self.domains,
         "imdb_id": imdb_id,
         "tmdb_id": tmdb_id
     }
     workers = ThreadPool(self.threadpool_size)
     if self.show_scraper_progress:
         self.PB = ProgressBar()
         self.PB.new('Searching for Movie Sources', self.enabled_scrapers)
         self.PB.results = 0
     self.threadpool_size = self.enabled_scrapers if self.threadpool_size == 0 else self.threadpool_size
     for index in range(0, self.enabled_scrapers):
         if self.show_scraper_progress and self.PB:
             if self.PB.is_canceled(): break
         service = self.get_scraper_by_index(index).service
         if self.cache_results:
             SQL = "SELECT result FROM fresh_cache WHERE hash=? AND service=?"
             results = DB.query(SQL, [self.hashid, service],
                                force_double_array=True)
             cached = [pickle.loads(r[0]) for r in results]
         else:
             cached = False
         if cached:
             number = len(cached)
             ADDON.log("Search returned %s cached links from %s" %
                       (number, service))
             if self.show_scraper_progress and self.PB:
                 self.PB.results += number
                 self.PB.next(
                     'Found [COLOR yellow]%s[/COLOR] cached sources (%s total)'
                     % (number, self.PB.results))
             self.search_results += cached
         else:
             if 'search_movie' in dir(self.get_scraper_by_index(index)):
                 if self.get_scraper_by_index(index).require_auth and (
                         ADDON.get_setting(service + '_username') == ''
                         or ADDON.get_setting(service + '_password') == ''):
                     continue
                 workers.queueTask(
                     self.get_scraper_by_index(index).search_movie,
                     args=args,
                     taskCallback=self.process_results)
             else:
                 print "bbbbbasdf"
                 print self.get_scraper_by_index(index).service
     workers.joinAll()
     resolved_url = None
     if self.cache_results:
         self.queue_SQL('EOL')
     DB.disconnect()
     if return_sources:
         return self.process_sources(self)
     else:
         raw_url, autoplay = self.select_stream()
         if raw_url:
             resolved_url = self.resolve_url(raw_url, autoplay)
         return resolved_url
예제 #8
0
	def notify(self, title, message):
		from dudehere.routines.plugin import Plugin
		image = vfs.join(ROOT_PATH, 'icon.png')
		Plugin().error_message(title, message, image=image)
예제 #9
0
import json
import urllib
import urllib2
import cookielib
import math
from dudehere.routines import *
from dudehere.routines.vfs import VFSClass
from dudehere.routines.plugin import Plugin
vfs = VFSClass()
plugin = Plugin()
COOKIE_PATH = vfs.join(DATA_PATH,'cookies')
MAX_PAGES = 3

class KatAPI():
	def __init__(self):
		self.base_url = 'https://kat.cr/'
		self.search_uri = 'json.php'
		self.headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',
			'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
			'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
			'Accept-Encoding': 'none',
			'Accept-Language': 'pl-PL,pl;q=0.8',
			'Connection': 'keep-alive'
		}
	
	def search(self, title, season='', episode='', year='', return_results=False, finished=True):
		if season and episode:
			query = "%s S%sE%s" % (title, str(season).zfill(2), str(episode).zfill(2))
			media = 'episode'
		elif year:
			query = "%s %s" % (title, year)