예제 #1
0
    def play_list(self, url):
        try:
            result = client.request(url)
            result = jsloads(result)
            items = result['items']
        except:
            pass

        for i in range(1, 5):
            try:
                if 'nextPageToken' not in result: raise Exception()
                next = url + '&pageToken=' + result['nextPageToken']
                result = client.request(next)
                result = jsloads(result)
                items += result['items']
            except:
                pass

        for item in items:
            try:
                title = item['snippet']['title']
                url = item['id']
                image = item['snippet']['thumbnails']['high']['url']
                if '/default.jpg' in image: raise Exception()
                image = image
                self.list.append({'title': title, 'url': url, 'image': image})
            except:
                pass
        return self.list
예제 #2
0
	def tvtuner(self, url):
		try:
			preset = re.findall(r'<preset>(.+?)</preset>', url)[0]
			today = datetime.now().strftime('%Y-%m-%d')
			today = int(re.sub(r'[^0-9]', '', str(today)))
			url, imdb, tvdb, tvshowtitle, year, thumbnail, fanart = re.findall(r'<url>(.+?)</url>', url)[0],
					re.findall(r'<imdb>(.+?)</imdb>', url)[0], 
					re.findall(r'<tvdb>(.+?)</tvdb>', url)[0], 
					re.findall(r'<tvshowtitle>(.+?)</tvshowtitle>', url)[0], 
					re.findall(r'<year>(.+?)</year>', url)[0], 
					re.findall(r'<thumbnail>(.+?)</thumbnail>', url)[0],
					re.findall(r'<fanart>(.+?)</fanart>', url)[0]
			tvm = client.request('https://api.tvmaze.com/lookup/shows?thetvdb=%s' % tvdb)
			if tvm  is None: tvm = client.request('https://api.tvmaze.com/lookup/shows?imdb=%s' % imdb)
			tvm ='https://api.tvmaze.com/shows/%s/episodes' % str(jsloads(tvm).get('id'))
			items = jsloads(client.request(tvm))
			items = [(str(i.get('season')), str(i.get('number')), i.get('name').strip(), i.get('airdate')) for i in items]
			if preset == 'tvtuner':
				choice = random.choice(items)
				items = items[items.index(choice):] + items[:items.index(choice)]
				items = items[:100]
			result = ''
			for i in items:
				try:
					if int(re.sub(r'[^0-9]', '', str(i[3]))) > today: raise Exception()
					result += '<item><title> %01dx%02d . %s</title><meta><content>episode</content><imdb>%s</imdb><tvdb>%s</tvdb><tvshowtitle>%s</tvshowtitle><year>%s</year><title>%s</title><premiered>%s</premiered><season>%01d</season><episode>%01d</episode></meta><link><sublink>search</sublink><sublink>searchsd</sublink></link><thumbnail>%s</thumbnail><fanart>%s</fanart></item>' % (int(i[0]), int(i[1]), i[2], imdb, tvdb, tvshowtitle, year, i[2], i[3], int(i[0]), int(i[1]), thumbnail, fanart)
				except: pass
			result = re.sub(r'[^\x00-\x7F]+', ' ', result)
			if preset == 'tvtuner': result = result.replace('<sublink>searchsd</sublink>', '')
			self.list = self.it_list('', result=result)
			if preset == 'tvtuner':
				self.addDirectory(self.list, queue=True)
			else:
				self.worker()
				self.addDirectory(self.list)
예제 #3
0
	def f4m(self, url, name):
			try:
				if not any(i in url for i in ['.f4m', '.ts']): raise Exception()
				ext = url.split('?')[0].split('&')[0].split('|')[0].rsplit('.')[-1].replace('/', '').lower()
				if not ext in ['f4m', 'ts']: raise Exception()

				params = parse_qs(url)

				try: proxy = params['proxy'][0]
				except: proxy = None

				try: proxy_use_chunks = jsloads(params['proxy_for_chunks'][0])
				except: proxy_use_chunks = True

				try: maxbitrate = int(params['maxbitrate'][0])
				except: maxbitrate = 0

				try: simpleDownloader = jsloads(params['simpledownloader'][0])
				except: simpleDownloader = False

				try: auth_string = params['auth'][0]
				except: auth_string = ''

				try: streamtype = params['streamtype'][0]
				except: streamtype = 'TSDOWNLOADER' if ext == 'ts' else 'HDS'

				try: swf = params['swf'][0]
				except: swf = None

				from F4mProxy import f4mProxyHelper
				return f4mProxyHelper().playF4mLink(url, name, proxy, proxy_use_chunks, maxbitrate, simpleDownloader, auth_string, streamtype, False, swf)
			except:
				log_utils.error()
예제 #4
0
	def resolve(self, url):
		try:
			api_key = self.get_api()
			if not api_key: return

			url = jsloads(url)
			file_id = url.get('file_id')
			self.content_type = 'movie' if url.get('content') == 'movie' else 'episode'
			if self.content_type == 'episode': self.filtering_list = self._seas_ep_resolve_list(url.get('season'), url.get('episode'))

			link = (self.base_link + self.tfile_link % (api_key, file_id))
			s = requests.Session()
			p = s.get(link)
			p = jsloads(p.text)
			if p['status'] != 'ok' or p['found_files'] != '1': return

			files = p['files'][0]
			files = files['t_files']
			for i in files:
				if 'video' not in i['ct']: pass
				else: self.files.append(i)
			url = self._manage_pack()
			return url
		except:
			source_utils.scraper_error('FURK')
예제 #5
0
def receive():
    messages = []
    inbox = jsloads(bitmessage.getAllInboxMessages())['inboxMessages']
    for msgid in (m['msgid'] for m in inbox):
        message = jsloads(bitmessage.getInboxMessageByID(msgid))['inboxMessage'][0]
        subject, message = map(b64dec, (message['subject'], message['message']))
        messages.append({'subject': subject, 'message': message})
        bitmessage.trashMessage(msgid)
    return messages
예제 #6
0
def playListItems():
	rpc = '{"jsonrpc": "2.0", "method": "Playlist.GetItems", "params": {"playlistid" : %s}, "id": 1 }' % Id
	result = control.jsonrpc(rpc)
	limits =jsloads(result)['result']['limits']
	total = limits['total']
	if int(total) <= 0: return []
	result = py_tools.ensure_text(result, errors='ignore')
	result = jsloads(result)['result']['items']
	try: return [i['label'] for i in result]
	except: return []
예제 #7
0
    def sources(self, data, hostDict):
        sources = []
        if not data: return sources
        try:
            if (self.user == '' or self.password == ''): return sources

            url = cache.get(self.ororo_tvcache, 120, self.user)
            if not url: return sources
            url = [i[0] for i in url if data['imdb'] == i[1]]
            if not url: return sources
            url = self.show_link % url[0]

            url = urljoin(self.base_link, url)
            r = client.request(url, headers=self.headers)
            r = jsloads(r)['episodes']
            r = [(str(i['id']), str(i['season']), str(i['number']),
                  str(i['airdate'])) for i in r]
            url = [
                i for i in r
                if data['season'] == i[1] and data['episode'] == i[2]
            ]
            url += [i for i in r if data['premiered'] == i[3]]
            if not url: return sources
            url = self.episode_link % url[0][0]

            url = urljoin(self.base_link, url)
            url = client.request(url, headers=self.headers)
            if not url: return sources
            url = jsloads(url)['url']
            # log_utils.log('url = %s' % url, __name__)

            name = re.sub(r'(.*?)\/video/file/(.*?)/', '',
                          url).split('.smil')[0].split('-')[0]
            quality, info = source_utils.get_release_quality(name)
            info = ' | '.join(info)

            sources.append({
                'provider': 'ororo',
                'source': 'direct',
                'name': name,
                'quality': quality,
                'language': 'en',
                'url': url,
                'info': info,
                'direct': True,
                'debridonly': False,
                'size': 0
            })  # Ororo does not return a file size
            return sources
        except:
            source_utils.scraper_error('ORORO')
            return sources
예제 #8
0
def receive():
    messages = []
    inbox = jsloads(bitmessage.getAllInboxMessages())['inboxMessages']
    for msgid in (m['msgid'] for m in inbox):
        message = jsloads(bitmessage.getInboxMessageByID(msgid))['inboxMessage'][0]
        if 'BM-' + toaddress == message['toAddress']:
            fromaddress = message['fromAddress']
            subject, body = map(b64dec, (message['subject'], message['message']))
            try: body = jsloads(body)
            except ValueError: pass
            messages.append({'subject': subject, 'body': body, 'fromaddress': fromaddress})
        bitmessage.trashMessage(msgid)
    if len(messages) > 0: print('transfered incoming messages: ', messages)
    return messages
예제 #9
0
	def browse_user_cloud(self, folder):
		sysaddon = sys.argv[0]
		syshandle = int(sys.argv[1])
		extensions = supported_video_extensions()
		torrent_folder = jsloads(folder)
		links = torrent_folder['links']
		links = [i for i in links if i['filename'].lower().endswith(tuple(extensions))]
		status_code = torrent_folder['statusCode'] 
		file_str, downloadMenu, deleteMenu = control.lang(40047).upper(), control.lang(40048), control.lang(40050)

		for count, item in enumerate(links, 1):
			try:
				cm = []
				url_link = item['link']
				name = control.strip_non_ascii_and_unprintable(item['filename'])
				size = item['size']
				display_size = float(int(size))/1073741824
				label = '%02d | [B]%s[/B] | %.2f GB | [I]%s [/I]' % (count, file_str, display_size, name)
				if status_code == 4:
					url = '%s?action=playURL&url=%s&caller=alldebrid&type=unrestrict' % (sysaddon, url_link)
				else:
					url = ''
				cm.append((downloadMenu, 'RunPlugin(%s?action=download&name=%s&image=%s&url=%s&caller=alldebrid)' %
								(sysaddon, quote_plus(name), quote_plus(ad_icon), url_link)))
				item = control.item(label=label)
				item.addContextMenuItems(cm)
				item.setArt({'icon': ad_icon, 'poster': ad_icon, 'thumb': ad_icon, 'fanart': addonFanart, 'banner': ad_icon})
				item.setInfo(type='video', infoLabels='')
				video_streaminfo = {'codec': 'h264'}
				item.addStreamInfo('video', video_streaminfo)
				control.addItem(handle=syshandle, url=url, listitem=item, isFolder=False)
			except:
				log_utils.error()
		control.content(syshandle, 'files')
		control.directory(syshandle, cacheToDisc=True)
예제 #10
0
    def sources(self, url, hostDict):
        sources = []
        if not url: return sources
        try:
            if (self.user == '' or self.password == ''): return sources

            url = urljoin(self.base_link, url)
            url = client.request(url, headers=self.headers)
            url = jsloads(url)['url']
            # log_utils.log('url = %s' % url, __name__, log_utils.LOGDEBUG)

            name = re.sub(r'(.*?)\/video/file/(.*?)/', '',
                          url).split('.smil')[0].split('-')[0]
            quality, info = source_utils.get_release_quality(name)

            sources.append({
                'provider': 'ororo',
                'source': 'direct',
                'name': name,
                'quality': quality,
                'language': 'en',
                'url': url,
                'info': info,
                'direct': True,
                'debridonly': False,
                'size': 0
            })  # Ororo does not return a file size
            return sources
        except:
            source_utils.scraper_error('ORORO')
            return sources
예제 #11
0
def trakt_user_list(self, url, user):
    try:
        result = trakt.getTrakt(url)
        items = jsloads(result)
    except:
        pass
    for item in items:
        try:
            try:
                name = item['list']['name']
            except:
                name = item['name']
            name = client.replaceHTMLCodes(name)
            try:
                url = (trakt.slug(item['list']['user']['username']),
                       item['list']['ids']['slug'])
            except:
                url = ('me', item['ids']['slug'])
            url = self.traktlist_link % url
            self.list.append({'name': name, 'url': url, 'context': url})
        except:
            pass
    self.list = sorted(
        self.list,
        key=lambda k: re.sub(r'(^the |^a |^an )', '', k['name'].lower()))
    return self.list
예제 #12
0
def _cacheProcess():
    data = database.Database(databaseName, connect=True)
    data._lock()
    _cacheCreate(data)
    data._unlock()
    try:
        while True:
            # Execute the select and delete as atomic operations.
            data._lock()
            result = data._selectSingle(
                'SELECT id, time, link, data FROM %s ORDER BY time ASC LIMIT 1;'
                % (databaseTable))
            if not result: raise Exception()
            data._delete('DELETE FROM %s WHERE id IS %d;' %
                         (databaseTable, result[0]),
                         commit=True)
            data._unlock()
            result = getTrakt(url=result[2],
                              post=jsloads(result[3]) if result[3] else None,
                              cache=True,
                              check=False,
                              timestamp=result[1])
    except:
        log_utils.error()
        data._unlock()
    data._close()
예제 #13
0
async def covid(event):
    try:
        url = 'http://67.158.54.51/corona.php'
        http = PoolManager()
        request = http.request('GET', url)
        result = jsloads(request.data.decode('utf-8'))
        http.clear()
    except:
        await event.edit("`Bir hata oluştu.`")
        return

    sonuclar = ("** Koronavirüs Verileri **\n" +
                "\n**Dünya geneli**\n" +
                f"**🌎 Vaka:** `{result['tum']}`\n" +
                f"**🌎 Ölüm:** `{result['tumolum']}`\n" +
                f"**🌎 İyileşen:** `{result['tumk']}`\n" +
                "\n**Türkiye**\n" +
                f"**🇹🇷 Vaka (toplam):** `{result['trtum']}`\n" +
                f"**🇹🇷 Vaka (bugün):** `{result['trbtum']}`\n" +
                f"**🇹🇷 Vaka (aktif):** `{result['tra']}`\n" +
                f"**🇹🇷 Ölüm (toplam):** `{result['trolum']}`\n" +
                f"**🇹🇷 Ölüm (bugün):** `{result['trbolum']}`\n" +
                f"**🇹🇷 İyileşen:** `{result['trk']}`")

    await event.edit(sonuclar)
예제 #14
0
async def covid(event):
    try:
        url = 'https://quiec.tech/corona.php'
        http = PoolManager()
        request = http.request('GET', url)
        result = jsloads(request.data.decode('utf-8'))
        http.clear()
    except:
        await event.edit("`Bir hata oluÅŸtu.`")
        return

    sonuclar = ("** Koronavirüs Verileri **\n" +
                "\n**Dünya geneli**\n" +
                f"**🌎 Vaka:** `{result['tum']}`\n" +
                f"**🌎 Ölüm:** `{result['tumolum']}`\n" +
                f"**🌎 İyileşen:** `{result['tumk']}`\n" +
                "\n**Türkiye**\n" +
                f"**🇹🇷 Vaka (toplam):** `{result['trtum']}`\n" +
                f"**🇹🇷 Vaka (bugün):** `{result['trbtum']}`\n" +
                f"**🇹🇷 Vaka (aktif):** `{result['tra']}`\n" +
                f"**🇹🇷 Ölüm (toplam):** `{result['trolum']}`\n" +
                f"**🇹🇷 Ölüm (bugün):** `{result['trbolum']}`\n" +
                f"**🇹🇷 İyileşen:** `{result['trk']}`")

    await event.edit(sonuclar)
예제 #15
0
	def traktHiddenManager(self, idx=True):
		control.busy()
		try:
			if trakt.getActivity() > cache.timeout(self.trakt_list, self.progress_link, self.trakt_user): raise Exception()
			self.list = cache.get(self.trakt_list, 24, self.progress_link, self.trakt_user)
		except:
			self.list = cache.get(self.trakt_list, 0, self.progress_link, self.trakt_user)
		try:
			hidden = cache.get(trakt.getTrakt, 0, self.hiddenprogress_link) # if this gets cached and user hides an item it's not instantly removed.
			hidden = jsloads(hidden)
			hidden = [str(i['show']['ids']['tvdb']) for i in hidden]
			for i in self.list: i.update({'isHidden': 'true'}) if i['tvdb'] in hidden else i.update({'isHidden': ''})
			if idx: self.worker()
			self.list = sorted(self.list, key=lambda k: re.sub(r'(^the |^a |^an )', '', k['tvshowtitle'].lower()), reverse=False)
			self.list = sorted(self.list, key=lambda k: k['isHidden'], reverse=True)
			control.hide()
			from resources.lib.windows.trakthidden_manager import TraktHiddenManagerXML
			window = TraktHiddenManagerXML('trakthidden_manager.xml', control.addonPath(control.addonId()), results=self.list)
			chosen_hide, chosen_unhide = window.run()
			del window
			if chosen_unhide:
				success = trakt.unHideItems(chosen_unhide)
				if success: control.notification(title='Trakt Hidden Progress Manager', message='Successfully Unhid %s Item%s' % (len(chosen_unhide), 's' if len(chosen_unhide) >1 else ''))
			if chosen_hide:
				success = trakt.hideItems(chosen_hide)
				if success: control.notification(title='Trakt Hidden Progress Manager', message='Successfully Hid %s Item%s' % (len(chosen_hide), 's' if len(chosen_hide) >1 else ''))
		except:
			from resources.lib.modules import log_utils
			log_utils.error()
예제 #16
0
    def load_checkpoint(self):
        '''
        Loads checkpoint file
        '''
        logging.debug('loading buffer')
        now = datetime.now(timezone.utc)
        curfile = path.join(self.checkpoint_dir,
                            '{}.json.gz'.format(now.strftime('%Y%m')))
        if path.exists(curfile):
            with GzipFile(curfile, 'r') as fin:
                inobj = jsloads(fin.read().decode('utf-8'))
                last_modified = inobj['metadata']['Last-Modified']
                logging.debug('Last-modified from checkpoint is {}'.format(
                    last_modified))
                features = inobj['features']
                logging.debug('Loaded {} features from checkpoint.'.format(
                    len(features)))
                tweets = inobj['tweets']
                logging.debug('Loaded {} tweets from checkpoint.'.format(
                    len(tweets)))

            min_time = int((now - self.buffer_tdelta).timestamp() * 1000)
            return last_modified, list(clean_features(
                min_time, features)), list(clean_tweets(min_time, tweets))
        return (now - timedelta(days=1)).timestamp(), list(), list()
예제 #17
0
def setting(id, fallback=None):
	try: settings_dict = jsloads(homeWindow.getProperty('fenomscrapers_settings'))
	except: settings_dict = make_settings_dict()
	if settings_dict is None: settings_dict = settings_fallback(id)
	value = settings_dict.get(id, '')
	if fallback is None: return value
	if value == '': return fallback
	return value
예제 #18
0
def read_terraform_json(filename):
    with open(filename, 'r') as jsonfile:
        data=jsonfile.read().replace('\n', '')
        # hack jsonload without unicode
        return _byteify(
                jsloads(data, object_hook=_byteify),
                ignore_dicts=False
        )
예제 #19
0
 def _get_token(self):
     try:
         token = self.scraper.get(self.token).content
         token = jsloads(token)[
             "token"]  # json can handle byte encoded strings
         return token
     except:
         source_utils.scraper_error('TORRENTAPI')
예제 #20
0
 def _get_token(self):
     try:
         token = self.scraper.get(self.token).content
         if not token: return '3qk6aj27ws'
         token = jsloads(token)["token"]
         return token
     except:
         source_utils.scraper_error('TORRENTAPI')
예제 #21
0
	def tv_info(self, i):
		try:
			if self.list[i]['metacache'] is True: raise Exception()
			if not self.list[i]['content'] in ['tvshows', 'seasons', 'episodes']: raise Exception()

			tvdb = self.list[i]['tvdb']
			if tvdb == '0': raise Exception()

			url = self.tvmaze_info_link % tvdb

			item = client.request(url, output='extended', error=True, timeout='10')

			if item[1] == '404':
				return self.meta.append({'imdb': '0', 'tmdb': '0', 'tvdb': tvdb, 'lang': self.lang, 'item': {'code': '0'}})

			item = jsloads(item[0])

			tvshowtitle = item['name']
			# tvshowtitle = tvshowtitle.encode('utf-8')
			if not tvshowtitle == '0': self.list[i].update({'tvshowtitle': tvshowtitle})

			year = item['premiered']
			year = re.findall(r'(\d{4})', year)[0]
			if not year == '0': self.list[i].update({'year': year})

			try: imdb = item['externals']['imdb']
			except: imdb = '0'
			if imdb == '' or imdb is None: imdb = '0'
			if self.list[i]['imdb'] == '0' and not imdb == '0': self.list[i].update({'imdb': imdb})

			try: studio = item['network']['name']
			except: studio = '0'
			if studio == '' or studio is None: studio = '0'
			if not studio == '0': self.list[i].update({'studio': studio})

			genre = item['genres']
			if genre == '' or genre is None or genre == []: genre = '0'
			genre = ' / '.join(genre)
			if not genre == '0': self.list[i].update({'genre': genre})

			try: duration = str(item['runtime'])
			except: duration = '0'
			if duration == '' or duration is None: duration = '0'
			try: duration = str(int(duration) * 60)
			except: pass
			if not duration == '0': self.list[i].update({'duration': duration})

			rating = str(item['rating']['average'])
			if rating == '' or rating is None: rating = '0'
			if not rating == '0': self.list[i].update({'rating': rating})

			plot = item['summary']
			if not plot: plot = '0'
			plot = re.sub(r'\n|<.+?>|</.+?>|.+?#\d*:', '', plot)
			if not plot == '0': self.list[i].update({'plot': plot})
			self.meta.append({'imdb': imdb, 'tmdb': '0', 'tvdb': tvdb, 'lang': self.lang, 'item': {'tvshowtitle': tvshowtitle, 'year': year, 'code': imdb, 'imdb': imdb, 'tvdb': tvdb, 'studio': studio, 'genre': genre, 'duration': duration, 'rating': rating, 'plot': plot}})
		except:
			log_utils.error()
예제 #22
0
	def request(self, endpoint, query=None):
		try:
			if query: query = '?' + urlencode(query)
			else: query = ''
			request = self.api_url % (endpoint, query)
			response = cache.get(client.request, 24, request)
			return jsloads(response)
		except: pass
		return {}
예제 #23
0
 def get_request(self, url):
     url = self.baseUrl + url
     response = requests.get(url, headers=self.headers).text
     if 'not authorized' in response.lower():
         self.renewToken()
         self.headers['Authorization'] = 'Bearer %s' % self.jwToken
         response = requests.get(url, headers=self.headers).text
     response = jsloads(response)
     return response
예제 #24
0
def playlistAdd(name, url, meta, art):
	labelPosition = position(label=name)
	if labelPosition >= 0:
		return control.notification(title=35522, message=32120)
	if isinstance(meta, py_tools.string_types):
		meta = jsloads(meta)
	if isinstance(art, py_tools.string_types):
		art = jsloads(art)
	try: item = control.item(label=name, offscreen=True)
	except: item = control.item(label=name)
	item.setArt(art)
	item.setProperty('IsPlayable', 'true')
	item.setInfo(type='video', infoLabels=control.metadataClean(meta))
	cm = []
	item.addContextMenuItems(cm)
	playlist().add(url=url, listitem=item)
	if notification:
		control.notification(title=35522, message=control.lang(32121) % str(name))
예제 #25
0
	def getNext_meta(self):
		try:
			from urllib.parse import parse_qsl
			current_position = control.playlist.getposition()
			next_url = control.playlist[current_position + 1].getPath()
			params = dict(parse_qsl(next_url.replace('?', '')))
			next_meta = jsloads(params.get('meta'))
			return next_meta
		except:
			log_utils.error()
예제 #26
0
	def search(self, url, type, name, year, imdb):
		try:
			apiLang = control.apiLanguage().get('youtube', 'en')
			if apiLang != 'en':
				url += "&relevanceLanguage=%s" % apiLang
			result = client.request(url, error=True)
			if 'error' in result:
				items = jsloads(result).get('error', []).get('errors', [])
				log_utils.log('message = %s' % str(items[0].get('message')), __name__, log_utils.LOGDEBUG)
				items = self.trakt_trailer(type, name, year, imdb)
			else:
				items = jsloads(result).get('items', [])
				items = [i.get('id', {}).get('videoId') for i in items]
			for vid_id in items:
				url = self.resolve(vid_id)
				if url: return url
		except:
			log_utils.error()
			return
예제 #27
0
	def _post_request(self, url, postData):
		postData = jsdumps(postData)
		url = self.baseUrl + url
		response = requests.post(url, data=postData, headers=self.headers).text
		if 'Not Authorized' in response:
			self.renewToken()
			self.headers['Authorization'] = 'Bearer %s' % self.jwToken
			response = requests.post(url, data=postData, headers=self.headers).text
		response = jsloads(response)
		return response
예제 #28
0
	def sources(self, url, hostDict):
		sources = []
		if not url: return sources
		try:
			data = parse_qs(url)
			data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data])

			title = data['title'].replace('&', 'and')
			aliases = data['aliases']
			hdlr = data['year']
			year = data['year']
			imdb = data['imdb']

			url = self.search_link % imdb
			api_url = urljoin(self.base_link, url)
			# log_utils.log('api_url = %s' % api_url, log_utils.LOGDEBUG)

			rjson = client.request(api_url, timeout='5')
			if not rjson: return sources
			files = jsloads(rjson)
			if files.get('status') == 'error' or files.get('data').get('movie_count') == 0:
				return sources
			title_long = files.get('data').get('movies')[0].get('title_long').replace(' ', '.')
			torrents = files.get('data').get('movies')[0].get('torrents')
		except:
			source_utils.scraper_error('YTSMX')
			return sources
		for torrent in torrents:
			try:
				quality = torrent.get('quality')
				type = torrent.get('type')
				hash = torrent.get('hash')
				name = '%s.[%s].[%s].[YTS.MX]' % (title_long, quality, type)
				url = 'magnet:?xt=urn:btih:%s&dn=%s' % (hash, name)
				if not source_utils.check_title(title, aliases, name, hdlr, year): continue
				name_info = source_utils.info_from_name(name, title, year, hdlr)
				if source_utils.remove_lang(name_info): continue
				try:
					seeders = torrent.get('seeds')
					if self.min_seeders > seeders: continue
				except: seeders = 0

				quality, info = source_utils.get_release_quality(name_info, url)
				try:
					size = torrent.get('size')
					dsize, isize = source_utils._size(size)
					info.insert(0, isize)
				except: dsize = 0
				info = ' | '.join(info)

				sources.append({'provider': 'ytsmx', 'source': 'torrent', 'seeders': seeders, 'hash': hash, 'name': name, 'name_info': name_info,
											'quality': quality, 'language': 'en', 'url': url, 'info': info, 'direct': False, 'debridonly': True, 'size': dsize})
			except:
				source_utils.scraper_error('YTSMX')
		return sources
예제 #29
0
 def renewToken(self):
     url = self.baseUrl + 'refresh_token'
     response = requests.post(url, headers=self.headers)
     response = jsloads(response.text)
     if 'Error' in response:
         self.newToken(True)
     else:
         self.jwToken = response['token']
         control.setSetting('tvdb.jw', self.jwToken)
         control.setSetting('tvdb.expiry', str(time() + (24 * (60 * 60))))
     return
예제 #30
0
 def ororo_tvcache(self, user):
     try:
         url = urljoin(self.base_link, self.tvsearch_link)
         r = client.request(url, headers=self.headers)
         r = jsloads(r)['shows']
         r = [(str(i['id']), str(i['imdb_id'])) for i in r]
         r = [(i[0], 'tt' + re.sub(r'[^0-9]', '', i[1])) for i in r]
         return r
     except:
         source_utils.scraper_error('ORORO')
         return
예제 #31
0
def check_title(title, aliases, release_title, hdlr, year, years=None):
    try:
        aliases = aliases_to_array(jsloads(aliases))
    except:
        aliases = None
    title_list = []
    title_list_append = title_list.append
    if aliases:
        for item in aliases:
            try:
                alias = item.replace('!', '').replace('(', '').replace(
                    ')', '').replace('&', 'and').replace(year, '')
                # alias = re.sub(r'[^A-Za-z0-9\s\.-]+', '', alias)
                if years:  # for movies only, scraper to pass None for episodes
                    for i in years:
                        alias = alias.replace(i, '')
                if alias in title_list: continue
                title_list_append(alias)
            except:
                from fenomscrapers.modules import log_utils
                log_utils.error()
    try:
        match = True
        title = title.replace('!',
                              '').replace('(',
                                          '').replace(')',
                                                      '').replace('&', 'and')
        # title = re.sub(r'[^A-Za-z0-9\s\.-]+', '', title)
        title_list_append(title)

        release_title = release_title_format(
            release_title)  # converts to .lower()
        h = hdlr.lower()
        t = release_title.split(h)[0].replace(year,
                                              '').replace('(', '').replace(
                                                  ')', '').replace('&', 'and')
        if years:
            for i in years:
                t = t.split(i)[0]
        t = t.split('2160p')[0].split('4k')[0].split('1080p')[0].split(
            '720p')[0]
        if all(cleantitle.get(i) != cleantitle.get(t) for i in title_list):
            match = False
        if years:  # for movies only, scraper to pass None for episodes
            if not any(value in release_title for value in years):
                match = False
        else:
            if h not in release_title: match = False
        return match
    except:
        from fenomscrapers.modules import log_utils
        log_utils.error()
        return match
예제 #32
0
	def ckKodiSources(self, paths=None):
		contains = False
		try:
			if paths is None:
				paths = []
				movie_LibraryFolder = control.joinPath(control.transPath(control.setting('library.movie')), '')
				special_movie_LibraryFolder = control.joinPath(control.setting('library.movie'), '')

				paths.append(movie_LibraryFolder)
				paths.append(special_movie_LibraryFolder)

				tvShows_LibraryFolder = control.joinPath(control.transPath(control.setting('library.tv')),'')
				speical_tvShows_LibraryFolder = control.joinPath(control.setting('library.tv'),'')

				paths.append(tvShows_LibraryFolder)
				paths.append(speical_tvShows_LibraryFolder)

			paths = [i.rstrip('/').rstrip('\\') for i in paths]
			result = control.jsonrpc('{"jsonrpc": "2.0", "method": "Files.GetSources", "params": {"media" : "video"}, "id": 1}')
			result = py_tools.ensure_text(result, errors='ignore')
			result = jsloads(result)['result']['sources']
			for i in result:
				if i['file'].rstrip('/').rstrip('\\') in paths:
					contains = True
					break
		except:
			log_utils.error()

		if not contains:
			try:
				global folder_setup
				global service_update
				if control.setting('library.service.update') == 'false' or service_update is False:
					return contains
				if folder_setup:
					contains = True
					return contains
				msg = 'Your Library Folders do not exist in Kodi Sources.  Would you like to run full setup of Library Folders to Kodi Sources now?'
				if control.yesnoDialog(msg, '', ''):
					lib_tools.total_setup()
					folder_setup = True
					contains = True
				else:
					msg = 'Would you like to turn off Library Auto Update Service?'
					if control.yesnoDialog(msg, '', ''):
						service_update = False
						control.setSetting('library.service.update', 'false')
						contains = False
						control.notification(message=32112)
						# control.refresh()
			except:
				log_utils.error()
		return contains