Exemplo n.º 1
0
	def process_results(self, soup):
		vfs = VFSClass()
		results = []

		blocks = soup.findAll('div', {"class": "postContent"})
		for block in blocks:
			links = block.findAll('p', {"style": "text-align: center;"})
			for link in links:
				files = link.findAll('a')
				size = re.search('\s(\d+\.??\d+)(MB|GB)', str(link))
				if size:
					if size.group(2) == 'MB':
						size = int(size.group(1)) * 1000 * 1000
					else:
						size = float(size.group(1)) * 1000 * 1000 * 1000

				for file in files:
					if file.text.lower() not in self.table: continue
					url = file['href']
					quality = self.test_quality(url, default=QUALITY.HIGH)
					host_name = self.table[file.text.lower()]
					path = vfs.path_parts(url)
					url = "%s://%s" % (self.service, url)
					try: 
						filename =  path['path'].split('/')[-1]
					except:
						filename = self.service
					result = ScraperResult(self.debrid_hosts, self.service, host_name, url, filename)
					result.quality = quality
					if size: result.size = size
					if path['extension'] != 'html':
						result.extension = path['extension']
					results += [result]
		return results
Exemplo n.º 2
0
	def get_videos(self, media):
		from dudehere.routines.vfs import VFSClass
		vfs = VFSClass()
		if media == 'tv':
			path = vfs.join(self.save_directory, "TV Shows")
		else:
			path = vfs.join(self.save_directory, "Movies")
		videos = vfs.ls(path, pattern="(avi|mp4|mkv|mov|flv)$")[1]
		return path, videos
Exemplo n.º 3
0
 def get_videos(self, media):
     from dudehere.routines.vfs import VFSClass
     vfs = VFSClass()
     if media == 'tv':
         path = vfs.join(self.save_directory, "TV Shows")
     else:
         path = vfs.join(self.save_directory, "Movies")
     videos = vfs.ls(path, pattern="(avi|mp4|mkv|mov|flv)$")[1]
     return path, videos
Exemplo n.º 4
0
	def clear_cache(self):
		if ADDON.get_setting('clear_cache') == "true":
			vfs = VFSClass()
			ADDON.log("Clearing download cache...")
			files = vfs.ls(WORK_DIRECTORY, pattern='state$|temp$|tail$')
			for foo in files[1]:
				path = vfs.join(WORK_DIRECTORY, foo)
				vfs.rm(path, quiet=True)
		ADDON.log("Clearing orphaned jobs...")
		self.DB.connect()
		self.DB.execute("UPDATE queue SET status=-1 WHERE status=2")
		self.DB.commit()
Exemplo n.º 5
0
	def get_cached_file(self, title, season=None, episode=None, year=None):
		from dudehere.routines.vfs import VFSClass
		vfs = VFSClass()
		if season is not None:
			for extension in ['avi', 'mkv', 'mov', 'mp4', 'flv']:
				path = vfs.join(self.save_directory, "TV Shows/%s %sx%s.%s" % (title, season, episode, extension))
				if vfs.exists(path):
					return path
			return False
		else:
			for extension in ['avi', 'mkv', 'mov', 'mp4', 'flv']:
				path = vfs.join(self.save_directory,"Movies/%s (%s).%s" % (title, year, extension))
				if vfs.exists(path):
					return path
			return False
Exemplo n.º 6
0
	def onPlayBackStopped(self):
		if get_property('streaming.started'):
			vfs = VFSClass()
			ADDON.log("Now I'm stopped")
			ADDON.log("Abort: %s" % get_property('file_id'))
			set_property("abort_id", get_property('file_id'))
			tail_file = vfs.join(WORK_DIRECTORY, get_property('file_id') + '.tail')
			if vfs.exists(tail_file):
				vfs.rm(tail_file,quiet=True)
			time.sleep(0.25)
			clear_property("abort_id")
			clear_property('playing')
			clear_property('file_id')
			clear_property('streaming.started')
			clear_property("streaming.total_bytes")
			clear_property("streaming.total_blocks")
			clear_property("streaming.file_id")
			clear_property("streaming.abort")
			clear_property("streaming.seek_block")
			clear_property('streaming.tail_requested')
Exemplo n.º 7
0
	def get_cached_file(self, title, season=None, episode=None, year=None):
		from dudehere.routines.vfs import VFSClass
		vfs = VFSClass()
		if season is not None:
			for extension in ['avi', 'mkv', 'mov', 'mp4', 'flv']:
				path = vfs.join(self.save_directory, "TV Shows/%s %sx%s.%s" % (title, season, episode, extension))
				if vfs.exists(path):
					return path
			return False
		else:
			for extension in ['avi', 'mkv', 'mov', 'mp4', 'flv']:
				path = vfs.join(self.save_directory,"Movies/%s (%s).%s" % (title, year, extension))
				if vfs.exists(path):
					return path
			return False
Exemplo n.º 8
0
    def draw(self):
        ''' Function draw
			initialize built-in functions
			this automatically called.
		'''
        if self.shade:
            self.create_image('shading',
                              VFSClass().join(
                                  TEXTURES, 'default/AddonWindow/shading.png'),
                              aspectRatio=1)
            self.add_object('shading',
                            0,
                            0,
                            columnspan=self._columns,
                            rowspan=self._rows,
                            pad_y=0)
        self.set_info_controls()
        self.set_active_controls()
        self.set_navigation()
        self.connect(pyxbmct.ACTION_NAV_BACK, self._cancel)
        self.__draw = True
Exemplo n.º 9
0
import sys
import os
import re
import json
import xbmc

from dudehere.routines import *
from dudehere.routines.scrapers import CommonScraper, ScraperResult
from dudehere.routines.vfs import VFSClass
vfs = VFSClass()

class localScraper(CommonScraper):
	def __init__(self):
		self.service='local'
		self.name = 'VideoLibrary'
		self.referrer = 'http://localhost'
		self.base_url = 'http://localhost'
		self.is_cachable = False
		self.get_debrid_hosts()
			
	def search_tvshow(self, args):
		results = []
		path = self.prepair_query('tvshow', args['showname'], args['season'], args['episode'], args['year'])
		if path:
			results = self.process_results(path)
		return self.get_response(results)
	
	def search_movie(self, args):
		results = []
		path = self.prepair_query('movie', args['title'], args['year'])
		if path:
Exemplo n.º 10
0
	along with this program.  If not, see <http://www.gnu.org/licenses/>.

'''
import sys, math
import xbmcgui, xbmcaddon

from dudehere.routines import *
from dudehere.routines.vfs import VFSClass
import dudehere.routines.addonwindow as pyxbmct
ACTION_ENTER = 13
ACTION_SELECT_ITEM = 7
ACTION_MOUSE_RIGHT_CLICK = 101
ACTION_SHOW_INFO = 11
ACTION_CONTEXT_MENU = 117
TEXTURES = VFSClass().join(
    xbmcaddon.Addon('script.module.dudehere.routines').getAddonInfo('path'),
    'resources/textures/')
'''
	The window wrapper extends the work by Roman_V_M script.module.pyxbmct.
	See http://forum.kodi.tv/showthread.php?tid=174859 for details.
	Documentation can be found at http://romanvm.github.io/PyXBMCt/docs/
	
	The purpose of this module is mainly to provide a interface for adding
	a window control that can be loaded through the manager class for creating
	multi-window forms.
	
	Additionally there are some helper functions for setting and getting stored values.
	There a couple of extra controls created by extending those currently provided.
	Nothing new here.	

'''
Exemplo n.º 11
0
#
## @package addonwindow
#  PyXBMCt framework module

import os
import xbmc
import xbmcgui
import xbmcaddon
from dudehere.routines import *
from dudehere.routines.vfs import VFSClass

#_ADDON_NAME = 'script.module.pyxbmct'
#_addon = xbmcaddon.Addon(id=_ADDON_NAME)
#_addon_path = _addon.getAddonInfo('path')
_images = VFSClass().join(
    xbmcaddon.Addon('script.module.dudehere.routines').getAddonInfo('path'),
    'resources/textures/default')

# Text alighnment constants. Mixed variants are obtained by bit OR (|)
ALIGN_LEFT = 0
ALIGN_RIGHT = 1
ALIGN_CENTER_X = 2
ALIGN_CENTER_Y = 4
ALIGN_CENTER = 6
ALIGN_TRUNCATED = 8
ALIGN_JUSTIFY = 10

# XBMC key action codes.
# More codes at https://github.com/xbmc/xbmc/blob/master/xbmc/guilib/Key.h
## ESC action
ACTION_PREVIOUS_MENU = 10
Exemplo n.º 12
0
	'Oxygen': '132',
	'PBS': '14|122|305',
	'Starz': '318',
	'Syfy': '77',
	'TBS': '49',
	'TV Land': '397',
	'The WB': '21|292',
	'TLC': '84',
	'TNT': '613',
	'Travel Channel': '209',
	'The History Channel': '238|560|893|894',
	'USA Network': '30',
	'VH1': '158',
}

vfs = VFSClass()
omdb = OMDBapi()

class MyDatabaseAPI(DatabaseAPI):
	def _initialize(self):
		do_init = True
		try:
			test = self.query("SELECT 1 FROM version WHERE db_version >= ?", [self.db_version])
			if test:
				do_init = False
		except:
			do_init = True
		if do_init:
			import xbmcaddon
			root = xbmcaddon.Addon('script.module.dudehere.routines').getAddonInfo('path')
			schema = vfs.join(root, 'resources/database/trakt.schema.sql')
Exemplo n.º 13
0
import re
import hashlib
import time
import base64
import datetime
import socket
from os import curdir, sep
from urlparse import urlparse
from SocketServer import ThreadingMixIn
from BaseHTTPServer import BaseHTTPRequestHandler
from dudehere.routines import *
from dudehere.routines.vfs import VFSClass
from resources.lib.common import *
from resources.lib.database import *
from resources.lib.transmogrifier import OutputHandler, Transmogrifier
vfs = VFSClass()
LOG_FILE = vfs.join(DATA_PATH, 'access.log')
ADDON.log("Setting Access log to: %s" % LOG_FILE)

def set_property(k, v):
	k = "%s.%s" % (WINDOW_PREFIX, k)
	xbmcgui.Window(10000).setProperty(k, str(v))
	
def get_property(k):
	k = "%s.%s" % (WINDOW_PREFIX, k)
	p = xbmcgui.Window(10000).getProperty(k)
	if p == 'false': return False
	if p == 'true': return True
	return p

class RequestHandler(BaseHTTPRequestHandler):
Exemplo n.º 14
0
import urllib
import urllib2
import json
import time
import unicodedata
import xbmcgui
import urlresolver
import hashlib
import random
from urlparse import urljoin
from dudehere.routines import *
from dudehere.routines.threadpool import ThreadPool
from addon.common.net import Net, HttpResponse
from BeautifulSoup import BeautifulSoup
from dudehere.routines.vfs import VFSClass
vfs = VFSClass()
DECAY = 2
SCRAPER_DIR = os.path.dirname(os.path.abspath(__file__))
COOKIE_PATH = vfs.join(DATA_PATH,'cookies')
if not vfs.exists(COOKIE_PATH): vfs.mkdir(COOKIE_PATH, recursive=True)
sys.path.append(SCRAPER_DIR)
RD_HOSTS = []
if ADDON.get_setting('database_type')=='1':
	DB_NAME = ADDON.get_setting('database_mysql_name')
	DB_USER = ADDON.get_setting('database_mysql_user')
	DB_PASS = ADDON.get_setting('database_mysql_pass')
	DB_PORT = ADDON.get_setting('database_mysql_port')
	DB_ADDRESS = ADDON.get_setting('database_mysql_host')
	DB_TYPE = 'mysql'
	from dudehere.routines.database import MySQLDatabase as DatabaseAPI
Exemplo n.º 15
0
except:
    import pickle as _pickle

pickle = _pickle.dumps

import xbmcaddon
import xbmcplugin
import xbmcgui
import xbmc
from xbmc import LOGDEBUG, LOGERROR, LOGFATAL, LOGINFO, LOGNONE, LOGNOTICE, LOGSEVERE, LOGWARNING
import xbmcvfs
import urllib
import urlparse
from dudehere.routines import *
from dudehere.routines.vfs import VFSClass
vfs = VFSClass()

addon = xbmcaddon.Addon()
__get_setting = addon.getSetting
__set_setting = addon.setSetting
show_settings = addon.openSettings
open_settings = show_settings
sleep = xbmc.sleep
get_condition_visiblity = xbmc.getCondVisibility
__log = xbmc.log
__dispatcher = {}
__kargs = {}

default_context_menu_items = []
replace_context_menu_by_default = True
Exemplo n.º 16
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)
Exemplo n.º 17
0
import json
import xbmcgui
from dudehere.routines import *
from dudehere.routines.vfs import VFSClass
vfs = VFSClass()
AUTH_PIN = ADDON.get_setting('auth_pin')

NUMBER_THREADS = int(ADDON.get_setting('thread_number'))
if ADDON.get_setting('enable_custom_work') == "true":
	WORK_DIRECTORY = ADDON.get_setting('work_directory')
else:
	WORK_DIRECTORY = vfs.join(DATA_PATH, 'work')

if ADDON.get_setting('enable_custom_output') == "true":
	CACHE_DIRECTORY = ADDON.get_setting('save_directory')
else:
	CACHE_DIRECTORY = vfs.join(DATA_PATH, 'downloads')

MOVIE_DIRECTORY = vfs.join(CACHE_DIRECTORY, 'Movies')
TVSHOW_DIRECTORY = vfs.join(CACHE_DIRECTORY, 'TV Shows')

BLOCK_SIZE = int(float(ADDON.get_setting('block_size')) * 1024 * 1024)
FRAME_SIZE = int(ADDON.get_setting('frame_size'))
RETRY_ATTEMPTS = int(ADDON.get_setting('retry_attempts'))

WINDOW_PREFIX = 'transmogrifier'
WEB_ROOT = vfs.join(ROOT_PATH, 'resources/www/html')
CONTROL_PORT = int(ADDON.get_setting('control_port'))
VALID_TOKENS = []

NOTIFICATION = ADDON.get_setting('notification')
Exemplo n.º 18
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)
Exemplo n.º 19
0
import traceback
import xbmcgui, xbmc
from dudehere.routines import *
from dudehere.routines.omdbapi import OMDBapi
from dudehere.routines.constants import WINDOW_ACTIONS
REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob'
BASE_URL = "http://api-v2launch.trakt.tv"
CLIENT_ID = ADDON.get_setting('trakt_client_id')
SECRET_ID = ADDON.get_setting('trakt_secret')
PIN_URL = ADDON.get_setting('trakt_pin_url')
DAYS_TO_GET = 21
DECAY = 2
from dudehere.routines import *
from dudehere.routines.vfs import VFSClass
from dudehere.routines.database import SQLiteDatabase as DatabaseAPI
vfs = VFSClass()
omdb = OMDBapi()

class MyDatabaseAPI(DatabaseAPI):
	def _initialize(self):
		import xbmcaddon
		root = xbmcaddon.Addon('script.module.dudehere.routines').getAddonInfo('path')
		schema_file = vfs.join(root, 'resources/database/trakt.schema.sql')
		if self.run_script(schema_file, commit=False):
			self.execute('DELETE FROM version WHERE 1')
			self.execute('INSERT INTO version(db_version) VALUES(?)', [self.db_version])
			self.commit()

	def do_init(self):
		do_init = True
		try:
Exemplo n.º 20
0
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.

*'''

import os
import sys
import xbmc
import xbmcaddon
from dudehere.routines.vfs import VFSClass
addon = xbmcaddon.Addon()
vfs = VFSClass()


def enum(*sequential, **named):
    enums = dict(zip(sequential, range(len(sequential))), **named)
    forward = dict((key, value) for key, value in enums.iteritems())
    reverse = dict((value, key) for key, value in enums.iteritems())
    enums['f_map'] = forward
    enums['r_map'] = reverse
    return type('Enum', (), enums)


def has_item(obj, key):
    if key in obj: return True
    for k, v in obj.items():
        if isinstance(v, dict):
import os
import re
import urllib, urllib2
import json
import unicodedata
import xbmcgui
import urlresolver
import hashlib
from dudehere.routines import *
from dudehere.routines.threadpool import ThreadPool
from addon.common.net import Net
from BeautifulSoup import BeautifulSoup
from dudehere.routines.vfs import VFSClass
from __builtin__ import None

vfs = VFSClass()
DECAY = 2
SCRAPER_DIR = os.path.dirname(os.path.abspath(__file__))
COOKIE_PATH = vfs.join(DATA_PATH, "cookies")
if not vfs.exists(COOKIE_PATH):
    vfs.mkdir(COOKIE_PATH, recursive=True)
sys.path.append(SCRAPER_DIR)

from dudehere.routines.database import SQLiteDatabase as DatabaseAPI


class MyDatabaseAPI(DatabaseAPI):
    def _initialize(self):
        SQL = """
			CREATE TABLE IF NOT EXISTS "search_cache" (
			"cache_id" INTEGER PRIMARY KEY AUTOINCREMENT,