Exemplo n.º 1
0
 def display_magnet_pack(self, magnet_url, info_hash):
     from modules.source_utils import supported_video_extensions
     try:
         end_results = []
         append = end_results.append
         extensions = supported_video_extensions()
         result = self.instant_transfer(magnet_url)
         if not 'status' in result or result['status'] != 'success':
             return None
         for item in result.get('content'):
             if any(
                     item.get('path').lower().endswith(x)
                     for x in extensions) and not item.get('link',
                                                           '') == '':
                 try:
                     path = item['path'].split('/')[-1]
                 except:
                     path = item['path']
                 append({
                     'link': item['link'],
                     'filename': path,
                     'size': item['size']
                 })
         return end_results
     except:
         return None
Exemplo n.º 2
0
def rd_external_browser(magnet, filtering_list):
    try:
        episode_match = False
        torrent_id = None
        torrent_keys = []
        append = torrent_keys.append
        extensions = supported_video_extensions()
        magnet_url = HTMLParser().unescape(magnet)
        r = re.search(r'''magnet:.+?urn:([a-zA-Z0-9]+):([a-zA-Z0-9]+)''',
                      str(magnet), re.I)
        infoHash = r.group(2).lower()
        torrent_files = RealDebrid.check_hash(infoHash)
        torrent_files = torrent_files[infoHash]['rd'][0]
        try:
            files_tuple = sorted([
                (k, v['filename'].lower()) for k, v in torrent_files.items()
                if v['filename'].lower().endswith(tuple(extensions))
            ])
        except:
            return None
        files_tuple.sort()
        for i in files_tuple:
            if any(x in i[1] for x in filtering_list):
                episode_match = True
            append(i[0])
        if not episode_match: return None
        if not torrent_keys: return None
        torrent_keys = ','.join(torrent_keys)
        torrent = RealDebrid.add_magnet(magnet_url)
        torrent_id = torrent['id']
        RealDebrid.add_torrent_select(torrent_id, torrent_keys)
        torrent_files = RealDebrid.user_cloud_info(torrent_id)
        file_info = [
            i for i in torrent_files['files']
            if i['path'].lower().endswith(tuple(extensions))
        ]
        file_urls = torrent_files['links']
        pack_info = [
            dict(i.items() + [('url_link', file_urls[c])])
            for c, i in enumerate(file_info)
        ]
        pack_info.sort(key=lambda k: k['path'])
        for item in pack_info:
            filename = clean_title(item['path'])
            if any(x in filename for x in filtering_list):
                correct_result = item
                break
        url_link = correct_result['url_link']
        RealDebrid.delete_torrent(torrent_id)
        return resolve_rd({'url': url_link, 'play': 'false'})
    except:
        if torrent_id: RealDebrid.delete_torrent(torrent_id)
        return None
Exemplo n.º 3
0
def browse_ad_cloud(folder):
    def _builder():
        for count, item in enumerate(links, 1):
            try:
                cm = []
                url_link = item['link']
                name = clean_file_name(item['filename']).upper()
                size = item['size']
                display_size = float(int(size)) / 1073741824
                display = '%02d | [B]%s[/B] | %.2f GB | [I]%s [/I]' % (
                    count, file_str, display_size, name)
                url_params = {
                    'mode': 'alldebrid.resolve_ad',
                    'url': url_link,
                    'play': 'true'
                }
                url = build_url(url_params)
                down_file_params = {
                    'mode': 'downloader',
                    'name': name,
                    'url': url_link,
                    'action': 'cloud.alldebrid',
                    'image': default_ad_icon
                }
                cm.append(
                    (down_str, 'RunPlugin(%s)' % build_url(down_file_params)))
                listitem = make_listitem()
                listitem.setLabel(display)
                listitem.addContextMenuItems(cm)
                listitem.setArt({
                    'icon': default_ad_icon,
                    'poster': default_ad_icon,
                    'thumb': default_ad_icon,
                    'fanart': fanart,
                    'banner': default_ad_icon
                })
                listitem.setInfo('video', {})
                yield (url, listitem, False)
            except:
                pass

    __handle__ = int(argv[1])
    file_str, down_str = ls(32743).upper(), ls(32747)
    extensions = supported_video_extensions()
    links = json.loads(folder)
    links = [
        i for i in links if i['filename'].lower().endswith(tuple(extensions))
    ]
    kodi_utils.add_items(__handle__, list(_builder()))
    kodi_utils.set_content(__handle__, 'files')
    kodi_utils.end_directory(__handle__)
    kodi_utils.set_view_mode('view.premium')
Exemplo n.º 4
0
	def results(self, info):
		try:
			if not enabled_debrids_check('ad'): return internal_results(self.scrape_provider, self.sources)
			self.title_filter = filter_by_name(self.scrape_provider)
			self.sources, self.folder_results, self.scrape_results = [], [], []
			self.db_type = info.get('db_type')
			self.title = info.get('title')
			self.year = info.get('year')
			if self.year: self.rootname = '%s (%s)' % (self.title, self.year)
			else: self.rootname = self.title
			self.season = info.get('season')
			self.episode = info.get('episode')
			if self.db_type == 'episode': self.seas_ep_query_list = seas_ep_query_list(self.season, self.episode)
			self.extensions = supported_video_extensions()
			self.folder_query = clean_title(normalize(self.title))
			self._scrape_cloud()
			if not self.scrape_results: return internal_results(self.scrape_provider, self.sources)
			self.aliases = get_aliases_titles(info.get('aliases', []))
			def _process():
				for item in self.scrape_results:
					try:
						file_name = normalize(item['filename'])
						if self.title_filter and not 'assigned_folder' in item:
							if not check_title(self.title, file_name, self.aliases, self.year, self.season, self.episode): continue
						file_dl = item['link']
						URLName = clean_file_name(file_name).replace('html', ' ').replace('+', ' ').replace('-', ' ')
						size = round(float(int(item['size']))/1073741824, 2)
						video_quality, details = get_file_info(name_info=release_info_format(file_name))
						source_item = {'name': file_name,
										'title': file_name,
										'URLName': URLName,
										'quality': video_quality,
										'size': size,
										'size_label': '%.2f GB' % size,
										'extraInfo': details,
										'url_dl': file_dl,
										'id': file_dl,
										'downloads': False,
										'direct': True,
										'source': self.scrape_provider,
										'scrape_provider': self.scrape_provider}
						yield source_item
					except: pass
			self.sources = list(_process())
		except Exception as e:
				from modules.kodi_utils import logger
				logger('FEN alldebrid scraper Exception', e)
		internal_results(self.scrape_provider, self.sources)
		return self.sources
Exemplo n.º 5
0
 def resolve_magnet(self, magnet_url, info_hash, store_to_cloud, title,
                    season, episode):
     from modules.source_utils import supported_video_extensions, seas_ep_filter, extras_filter
     try:
         file_url = None
         correct_files = []
         append = correct_files.append
         extensions = supported_video_extensions()
         extras_filtering_list = extras_filter()
         result = self.instant_transfer(magnet_url)
         if not 'status' in result or result['status'] != 'success':
             return None
         valid_results = [
             i for i in result.get('content')
             if any(i.get('path').lower().endswith(x)
                    for x in extensions) and not i.get('link', '') == ''
         ]
         if len(valid_results) == 0: return
         if season:
             episode_title = re.sub(
                 r'[^A-Za-z0-9-]+', '.',
                 title.replace('\'', '').replace('&', 'and').replace(
                     '%', '.percent')).lower()
             for item in valid_results:
                 if seas_ep_filter(season, episode,
                                   item['path'].split('/')[-1]):
                     append(item)
                 if len(correct_files) == 0: continue
                 for i in correct_files:
                     compare_link = seas_ep_filter(season,
                                                   episode,
                                                   i['path'],
                                                   split=True)
                     compare_link = re.sub(episode_title, '', compare_link)
                     if not any(x in compare_link
                                for x in extras_filtering_list):
                         file_url = i['link']
                         break
         else:
             file_url = max(valid_results,
                            key=lambda x: int(x.get('size'))).get(
                                'link', None)
             if not any(file_url.lower().endswith(x) for x in extensions):
                 file_url = None
         if file_url:
             if store_to_cloud: self.create_transfer(magnet_url)
             return self.add_headers_to_url(file_url)
     except:
         return None
Exemplo n.º 6
0
 def resolve_magnet(self, magnet_url, info_hash, store_to_cloud, title,
                    season, episode):
     from modules.source_utils import supported_video_extensions, seas_ep_filter, extras_filter
     try:
         file_url = None
         correct_files = []
         append = correct_files.append
         extensions = supported_video_extensions()
         extras_filtering_list = extras_filter()
         transfer_id = self.create_transfer(magnet_url)
         transfer_info = self.list_transfer(transfer_id)
         valid_results = [
             i for i in transfer_info.get('links') if any(
                 i.get('filename').lower().endswith(x)
                 for x in extensions) and not i.get('link', '') == ''
         ]
         if len(valid_results) == 0: return
         if season:
             episode_title = re.sub(
                 r'[^A-Za-z0-9-]+', '.',
                 title.replace('\'', '').replace('&', 'and').replace(
                     '%', '.percent')).lower()
             for item in valid_results:
                 if seas_ep_filter(season, episode, item['filename']):
                     append(item)
                 if len(correct_files) == 0: continue
                 for i in correct_files:
                     compare_link = seas_ep_filter(season,
                                                   episode,
                                                   i['filename'],
                                                   split=True)
                     compare_link = re.sub(episode_title, '', compare_link)
                     if not any(x in compare_link
                                for x in extras_filtering_list):
                         media_id = i['link']
                         break
         else:
             media_id = max(valid_results,
                            key=lambda x: x.get('size')).get('link', None)
         if not store_to_cloud: self.delete_transfer(transfer_id)
         file_url = self.unrestrict_link(media_id)
         if not any(file_url.lower().endswith(x) for x in extensions):
             file_url = None
         return file_url
     except Exception:
         if transfer_id: self.delete_transfer(transfer_id)
         return None
Exemplo n.º 7
0
 def create_transfer(self, magnet_url):
     from modules.source_utils import supported_video_extensions
     try:
         extensions = supported_video_extensions()
         torrent = self.add_magnet(magnet_url)
         torrent_id = torrent['id']
         info = self.torrent_info(torrent_id)
         files = info['files']
         torrent_keys = [
             str(item['id']) for item in files
             if item['path'].lower().endswith(tuple(extensions))
         ]
         torrent_keys = ','.join(torrent_keys)
         self.add_torrent_select(torrent_id, torrent_keys)
         return 'success'
     except:
         self.delete_torrent(torrent_id)
         return 'failed'
Exemplo n.º 8
0
 def display_magnet_pack(self, magnet_url, info_hash):
     from modules.source_utils import supported_video_extensions
     try:
         video_only_items = []
         list_file_items = []
         append = video_only_items.append
         extensions = supported_video_extensions()
         torrent_files = self.check_hash(info_hash)
         if not info_hash in torrent_files: return None
         torrent = self.add_magnet(magnet_url)
         torrent_id = torrent['id']
         torrent_files = torrent_files[info_hash]['rd']
         torrent_files = [
             item for item in torrent_files
             if self._video_only(item, extensions)
         ]
         for item in torrent_files:
             torrent_keys = item.keys()
             if len(torrent_keys) == 0: continue
             append(torrent_keys)
         video_only_items = max(video_only_items, key=len)
         torrent_keys = ','.join(video_only_items)
         self.add_torrent_select(torrent_id, torrent_keys)
         torrent_info = self.user_cloud_info(torrent_id)
         list_file_items = [
             dict(i, **{'link': torrent_info['links'][idx]})
             for idx, i in enumerate(
                 [i for i in torrent_info['files'] if i['selected'] == 1])
         ]
         list_file_items = [{
             'link': i['link'],
             'filename': i['path'].replace('/', ''),
             'size': i['bytes']
         } for i in list_file_items]
         self.delete_torrent(torrent_id)
         return list_file_items
     except Exception:
         if torrent_id: self.delete_torrent(torrent_id)
         return None
Exemplo n.º 9
0
 def display_magnet_pack(self, magnet_url, info_hash):
     from modules.source_utils import supported_video_extensions
     try:
         extensions = supported_video_extensions()
         transfer_id = self.create_transfer(magnet_url)
         transfer_info = self.list_transfer(transfer_id)
         end_results = []
         append = end_results.append
         for item in transfer_info.get('links'):
             if any(
                     item.get('filename').lower().endswith(x)
                     for x in extensions) and not item.get('link',
                                                           '') == '':
                 append({
                     'link': item['link'],
                     'filename': item['filename'],
                     'size': item['size']
                 })
         self.delete_transfer(transfer_id)
         return end_results
     except Exception:
         if transfer_id: self.delete_transfer(transfer_id)
         return None
Exemplo n.º 10
0
    def add_uncached_torrent(self, magnet_url, pack=False):
        from modules.kodi_utils import show_busy_dialog, hide_busy_dialog
        from modules.source_utils import supported_video_extensions

        def _return_failed(message=32574, cancelled=False):
            try:
                progressDialog.close()
            except Exception:
                pass
            hide_busy_dialog()
            sleep(500)
            if cancelled:
                if confirm_dialog(text=32044, top_space=True):
                    ok_dialog(heading=32733, text=ls(32732) % ls(32054))
                else:
                    self.delete_torrent(torrent_id)
            else:
                ok_dialog(heading=32733, text=message)
            return False

        show_busy_dialog()
        try:
            active_count = self.torrents_activeCount()
            if active_count['nb'] >= active_count['limit']:
                return _return_failed()
        except:
            pass
        interval = 5
        stalled = ('magnet_error', 'error', 'virus', 'dead')
        extensions = supported_video_extensions()
        torrent = self.add_magnet(magnet_url)
        torrent_id = torrent['id']
        if not torrent_id: return _return_failed()
        torrent_info = self.torrent_info(torrent_id)
        if 'error_code' in torrent_info: return _return_failed()
        status = torrent_info['status']
        line = '%s[CR]%s[CR]%s'
        if status == 'magnet_conversion':
            line1 = ls(32737)
            line2 = torrent_info['filename']
            line3 = ls(32738) % torrent_info['seeders']
            timeout = 100
            progressDialog.create(ls(32733), line % (line1, line2, line3))
            while status == 'magnet_conversion' and timeout > 0:
                progressDialog.update(timeout, line % (line1, line2, line3))
                if monitor.abortRequested() == True: return sysexit()
                try:
                    if progressDialog.iscanceled():
                        return _return_failed(32736, cancelled=True)
                except Exception:
                    pass
                timeout -= interval
                sleep(1000 * interval)
                torrent_info = self.torrent_info(torrent_id)
                status = torrent_info['status']
                if any(x in status for x in stalled):
                    return _return_failed()
                line3 = ls(32738) % torrent_info['seeders']
            try:
                progressDialog.close()
            except Exception:
                pass
        if status == 'downloaded':
            hide_busy_dialog()
            return True
        if status == 'magnet_conversion':
            return _return_failed()
        if any(x in status for x in stalled):
            return _return_failed(str(status))
        if status == 'waiting_files_selection':
            video_files = []
            append = video_files.append
            all_files = torrent_info['files']
            for item in all_files:
                if any(item['path'].lower().endswith(x) for x in extensions):
                    append(item)
            if pack:
                try:
                    if len(video_files) == 0: return _return_failed()
                    video_files.sort(key=lambda x: x['path'])
                    torrent_keys = [str(i['id']) for i in video_files]
                    if not torrent_keys: return _return_failed(ls(32736))
                    torrent_keys = ','.join(torrent_keys)
                    self.add_torrent_select(torrent_id, torrent_keys)
                    ok_dialog(text=ls(32732) % ls(32054))
                    self.clear_cache()
                    hide_busy_dialog()
                    return True
                except Exception:
                    return _return_failed()
            else:
                try:
                    video = max(video_files, key=lambda x: x['bytes'])
                    file_id = video['id']
                except ValueError:
                    return _return_failed()
                self.add_torrent_select(torrent_id, str(file_id))
            sleep(2000)
            torrent_info = self.torrent_info(torrent_id)
            status = torrent_info['status']
            if status == 'downloaded':
                hide_busy_dialog()
                return True
            file_size = round(float(video['bytes']) / (1000**3), 2)
            line1 = '%s...' % (ls(32732) % ls(32054))
            line2 = torrent_info['filename']
            line3 = status
            progressDialog.create(ls(32733), line % (line1, line2, line3))
            while not status == 'downloaded':
                sleep(1000 * interval)
                torrent_info = self.torrent_info(torrent_id)
                status = torrent_info['status']
                if status == 'downloading':
                    line3 = ls(32739) % (
                        file_size,
                        round(float(torrent_info['speed']) / (1000**2), 2),
                        torrent_info['seeders'], torrent_info['progress'])
                else:
                    line3 = status
                progressDialog.update(int(float(torrent_info['progress'])),
                                      line % (line1, line2, line3))
                if monitor.abortRequested() == True: return sys.exit()
                try:
                    if progressDialog.iscanceled():
                        return _return_failed(32736, cancelled=True)
                except:
                    pass
                if any(x in status for x in stalled): return _return_failed()
            try:
                progressDialog.close()
            except:
                pass
            hide_busy_dialog()
            return True
        hide_busy_dialog()
        return False
Exemplo n.º 11
0
 def resolve_magnet(self, magnet_url, info_hash, store_to_cloud, title,
                    season, episode):
     from modules.source_utils import supported_video_extensions, seas_ep_filter, extras_filter
     try:
         torrent_id, rd_url, match = None, None, False
         extensions = supported_video_extensions()
         extras_filtering_list = extras_filter()
         torrent_files = self.check_hash(info_hash)
         if not info_hash in torrent_files: return None
         torrent = self.add_magnet(magnet_url)
         torrent_id = torrent['id']
         torrent_files = torrent_files[info_hash]['rd']
         torrent_files = [
             item for item in torrent_files
             if self._video_only(item, extensions)
         ]
         if season:
             episode_title = re.sub(
                 r'[^A-Za-z0-9-]+', '.',
                 title.replace('\'', '').replace('&', 'and').replace(
                     '%', '.percent')).lower()
         else:
             m2ts_check = self._m2ts_check(torrent_files)
             if m2ts_check:
                 m2ts_key, torrent_files = self._m2ts_key_value(
                     torrent_files)
             else:
                 torrent_files = self.sort_cache_list([
                     (item, max([i['filesize'] for i in item.values()]))
                     for item in torrent_files
                 ])
         for item in torrent_files:
             try:
                 if season:
                     item_values = [i['filename'] for i in item.values()]
                     for value in item_values:
                         correct_file_check = seas_ep_filter(
                             season, episode, value)
                         if correct_file_check: break
                     if not correct_file_check: continue
                 elif not m2ts_check:
                     item_values = self.sort_cache_list([
                         (i['filename'], i['filesize'])
                         for i in item.values()
                     ])
                     for value in item_values:
                         filename = re.sub(
                             r'[^A-Za-z0-9-]+', '.',
                             value.replace('\'',
                                           '').replace('&', 'and').replace(
                                               '%', '.percent')).lower()
                         if any(x in filename
                                for x in extras_filtering_list):
                             continue
                         break
                 torrent_keys = item.keys()
                 if len(torrent_keys) == 0: continue
                 torrent_keys = ','.join(torrent_keys)
                 self.add_torrent_select(torrent_id, torrent_keys)
                 torrent_info = self.user_cloud_info(torrent_id)
                 if 'error' in torrent_info: continue
                 selected_files = [(idx, i) for idx, i in enumerate([
                     i for i in torrent_info['files'] if i['selected'] == 1
                 ])]
                 if season:
                     correct_files = []
                     correct_file_check = False
                     for value in selected_files:
                         correct_file_check = seas_ep_filter(
                             season, episode, value[1]['path'])
                         if correct_file_check:
                             correct_files.append(value[1])
                             break
                     if len(correct_files) == 0: continue
                     for i in correct_files:
                         compare_link = seas_ep_filter(season,
                                                       episode,
                                                       i['path'],
                                                       split=True)
                         compare_link = re.sub(episode_title, '',
                                               compare_link)
                         if any(x in compare_link
                                for x in extras_filtering_list):
                             continue
                         else:
                             match = True
                             break
                     if match:
                         index = [
                             i[0] for i in selected_files
                             if i[1]['path'] == correct_files[0]['path']
                         ][0]
                         break
                 elif m2ts_check:
                     match, index = True, [
                         i[0] for i in selected_files
                         if i[1]['id'] == m2ts_key
                     ][0]
                     break
                 else:
                     match = False
                     for value in selected_files:
                         filename = re.sub(
                             r'[^A-Za-z0-9-]+', '.',
                             value[1]['path'].rsplit('/', 1)[1].replace(
                                 '\'', '').replace('&', 'and').replace(
                                     '%', '.percent')).lower()
                         if any(x in filename
                                for x in extras_filtering_list):
                             continue
                         match, index = True, value[0]
                         break
                     if match: break
             except:
                 pass
         if match:
             rd_link = torrent_info['links'][index]
             file_url = self.unrestrict_link(rd_link)
             if file_url.endswith('rar'): file_url = None
             if not any(file_url.lower().endswith(x) for x in extensions):
                 file_url = None
             if not store_to_cloud: self.delete_torrent(torrent_id)
             return file_url
         self.delete_torrent(torrent_id)
     except Exception:
         if torrent_id: self.delete_torrent(torrent_id)
         return None
Exemplo n.º 12
0
def pm_torrent_cloud(folder_id=None, folder_name=None):
    def _builder():
        for count, item in enumerate(cloud_files, 1):
            try:
                cm = []
                cm_append = cm.append
                file_type = item['type']
                name = clean_file_name(item['name']).upper()
                rename_params = {
                    'mode': 'premiumize.rename',
                    'file_type': file_type,
                    'id': item['id'],
                    'name': item['name']
                }
                delete_params = {'mode': 'premiumize.delete', 'id': item['id']}
                if file_type == 'folder':
                    is_folder = True
                    download_string = archive_str
                    delete_params['file_type'] = 'folder'
                    string = folder_str
                    display = '%02d | [B]%s[/B] | [I]%s [/I]' % (
                        count, folder_str, name)
                    url_params = {
                        'mode': 'premiumize.pm_torrent_cloud',
                        'id': item['id'],
                        'folder_name': normalize(item['name'])
                    }
                else:
                    is_folder = False
                    download_string = down_str
                    delete_params['file_type'] = 'item'
                    string = file_str
                    url_link = item['link']
                    if url_link.startswith('/'): url_link = 'https' + url_link
                    size = item['size']
                    display_size = float(int(size)) / 1073741824
                    display = '%02d | [B]%s[/B] | %.2f GB | [I]%s [/I]' % (
                        count, file_str, display_size, name)
                    url_params = {
                        'mode': 'media_play',
                        'url': url_link,
                        'media_type': 'video'
                    }
                    down_file_params = {
                        'mode': 'downloader',
                        'name': item['name'],
                        'url': url_link,
                        'action': 'cloud.premiumize',
                        'image': default_pm_icon
                    }
                    cm_append((download_string,
                               'RunPlugin(%s)' % build_url(down_file_params)))
                cm_append((rename_str % file_type.capitalize(),
                           'RunPlugin(%s)' % build_url(rename_params)))
                cm_append(('[B]%s %s[/B]' % (delete_str, string.capitalize()),
                           'RunPlugin(%s)' % build_url(delete_params)))
                url = build_url(url_params)
                listitem = make_listitem()
                listitem.setLabel(display)
                listitem.addContextMenuItems(cm)
                listitem.setArt({
                    'icon': default_pm_icon,
                    'poster': default_pm_icon,
                    'thumb': default_pm_icon,
                    'fanart': fanart,
                    'banner': default_pm_icon
                })
                yield (url, listitem, is_folder)
            except:
                pass

    __handle__ = int(argv[1])
    folder_str, file_str, down_str, archive_str, rename_str, delete_str = ls(
        32742).upper(), ls(32743).upper(), ls(32747), ls(32982), ls(32748), ls(
            32785)
    extensions = supported_video_extensions()
    cloud_files = Premiumize.user_cloud(folder_id)['content']
    cloud_files = [
        i for i in cloud_files
        if ('link' in i and i['link'].lower().endswith(tuple(extensions)))
        or i['type'] == 'folder'
    ]
    cloud_files.sort(key=lambda k: k['name'])
    cloud_files.sort(key=lambda k: k['type'], reverse=True)
    kodi_utils.add_items(__handle__, list(_builder()))
    kodi_utils.set_content(__handle__, 'files')
    kodi_utils.end_directory(__handle__)
    kodi_utils.set_view_mode('view.premium')
Exemplo n.º 13
0
	def __init__(self, scrape_provider, scraper_name):
		self.scrape_provider = scrape_provider
		self.scraper_name = scraper_name
		self.title_filter = filter_by_name('folders')
		self.extensions = supported_video_extensions()
		self.sources, self.scrape_results = [], []
Exemplo n.º 14
0
def rd_downloads():
    def _builder():
        for count, item in enumerate(my_downloads, 1):
            try:
                cm = []
                cm_append = cm.append
                datetime_object = jsondate_to_datetime(item['generated'],
                                                       '%Y-%m-%dT%H:%M:%S.%fZ',
                                                       remove_time=True)
                filename = item['filename']
                name = clean_file_name(filename).upper()
                size = float(int(item['filesize'])) / 1073741824
                display = '%02d | %.2f GB | %s  | [I]%s [/I]' % (
                    count, size, datetime_object, name)
                url_link = item['download']
                url_params = {
                    'mode': 'media_play',
                    'url': url_link,
                    'media_type': 'video'
                }
                down_file_params = {
                    'mode': 'downloader',
                    'name': name,
                    'url': url_link,
                    'action': 'cloud.realdebrid_direct',
                    'image': default_rd_icon
                }
                delete_params = {
                    'mode': 'real_debrid.delete',
                    'id': item['id'],
                    'cache_type': 'download'
                }
                cm_append(
                    (down_str, 'RunPlugin(%s)' % build_url(down_file_params)))
                cm_append(
                    ('[B]%s %s[/B]' % (delete_str, file_str.capitalize()),
                     'RunPlugin(%s)' % build_url(delete_params)))
                url = build_url(url_params)
                listitem = make_listitem()
                listitem.setLabel(display)
                listitem.addContextMenuItems(cm)
                listitem.setArt({
                    'icon': default_rd_icon,
                    'poster': default_rd_icon,
                    'thumb': default_rd_icon,
                    'fanart': fanart,
                    'banner': default_rd_icon
                })
                yield (url, listitem, True)
            except:
                pass

    __handle__ = int(argv[1])
    try:
        my_downloads = RealDebrid.downloads()
    except:
        return
    extensions = supported_video_extensions()
    my_downloads = [
        i for i in my_downloads
        if i['download'].lower().endswith(tuple(extensions))
    ]
    file_str, down_str, delete_str = ls(32743), ls(32747), ls(32785)
    kodi_utils.add_items(__handle__, list(_builder()))
    kodi_utils.set_content(__handle__, 'files')
    kodi_utils.end_directory(__handle__)
    kodi_utils.set_view_mode('view.premium')
Exemplo n.º 15
0
def browse_rd_cloud(folder_id):
    def _builder():
        for count, item in enumerate(pack_info, 1):
            try:
                cm = []
                name = item['path']
                if name.startswith('/'): name = name.split('/')[-1]
                name = clean_file_name(name).upper()
                url_link = item['url_link']
                if url_link.startswith('/'): url_link = 'http' + url_link
                size = float(int(item['bytes'])) / 1073741824
                display = '%02d | [B]%s[/B] | %.2f GB | [I]%s [/I]' % (
                    count, file_str, size, name)
                url_params = {
                    'mode': 'real_debrid.resolve_rd',
                    'url': url_link,
                    'play': 'true'
                }
                url = build_url(url_params)
                down_file_params = {
                    'mode': 'downloader',
                    'name': name,
                    'url': url_link,
                    'action': 'cloud.realdebrid',
                    'image': default_rd_icon
                }
                cm.append(
                    (down_str, 'RunPlugin(%s)' % build_url(down_file_params)))
                listitem = make_listitem()
                listitem.setLabel(display)
                listitem.addContextMenuItems(cm)
                listitem.setArt({
                    'icon': default_rd_icon,
                    'poster': default_rd_icon,
                    'thumb': default_rd_icon,
                    'fanart': fanart,
                    'banner': default_rd_icon
                })
                listitem.setInfo('video', {})
                yield (url, listitem, False)
            except:
                pass

    __handle__ = int(argv[1])
    torrent_files = RealDebrid.user_cloud_info(folder_id)
    extensions = supported_video_extensions()
    file_info = [
        i for i in torrent_files['files']
        if i['path'].lower().endswith(tuple(extensions))
    ]
    file_urls = torrent_files['links']
    for c, i in enumerate(file_info):
        try:
            i.update({'url_link': file_urls[c]})
        except:
            pass
    pack_info = sorted(file_info, key=lambda k: k['path'])
    file_str, down_str = ls(32743).upper(), ls(32747)
    kodi_utils.add_items(__handle__, list(_builder()))
    kodi_utils.set_content(__handle__, 'files')
    kodi_utils.end_directory(__handle__)
    kodi_utils.set_view_mode('view.premium')
Exemplo n.º 16
0
    def add_uncached_torrent(self, magnet_url, pack=False):
        from modules.kodi_utils import show_busy_dialog, hide_busy_dialog
        from modules.source_utils import supported_video_extensions

        def _transfer_info(transfer_id):
            info = self.transfers_list()
            if 'status' in info and info['status'] == 'success':
                for item in info['transfers']:
                    if item['id'] == transfer_id:
                        return item
            return {}

        def _return_failed(message=32574, cancelled=False):
            try:
                progressDialog.close()
            except Exception:
                pass
            hide_busy_dialog()
            sleep(500)
            if cancelled:
                if confirm_dialog(heading=32733, text=32044, top_space=True):
                    ok_dialog(heading=32733, text=ls(32732) % ls(32061))
                else:
                    self.delete_transfer(transfer_id)
            else:
                ok_dialog(heading=32733, text=message)
            return False

        show_busy_dialog()
        extensions = supported_video_extensions()
        transfer_id = self.create_transfer(magnet_url)
        if not transfer_id['status'] == 'success':
            return _return_failed(transfer_id.get('message'))
        transfer_id = transfer_id['id']
        transfer_info = _transfer_info(transfer_id)
        if not transfer_info: return _return_failed()
        if pack:
            self.clear_cache()
            hide_busy_dialog()
            ok_dialog(text=ls(32732) % ls(32061))
            return True
        interval = 5
        line = '%s[CR]%s[CR]%s'
        line1 = '%s...' % (ls(32732) % ls(32061))
        line2 = transfer_info['name']
        line3 = transfer_info['message']
        progressDialog.create(ls(32733), line % (line1, line2, line3))
        while not transfer_info['status'] == 'seeding':
            sleep(1000 * interval)
            transfer_info = _transfer_info(transfer_id)
            line3 = transfer_info['message']
            progressDialog.update(int(float(transfer_info['progress']) * 100),
                                  line % (line1, line2, line3))
            if monitor.abortRequested() == True: return sysexit()
            try:
                if progressDialog.iscanceled():
                    return _return_failed(ls(32736), cancelled=True)
            except Exception:
                pass
            if transfer_info.get('status') == 'stalled':
                return _return_failed()
        sleep(1000 * interval)
        try:
            progressDialog.close()
        except Exception:
            pass
        hide_busy_dialog()
        return True
Exemplo n.º 17
0
def pm_transfers():
    def _builder():
        for count, item in enumerate(transfer_files, 1):
            try:
                cm = []
                file_type = 'folder' if item['file_id'] is None else 'file'
                name = clean_file_name(item['name']).upper()
                status = item['status']
                progress = item['progress']
                if status == 'finished': progress = 100
                else:
                    try:
                        progress = re.findall(r'\.{0,1}(\d+)',
                                              str(progress))[0][:2]
                    except:
                        progress = ''
                if file_type == 'folder':
                    is_folder = True if status == 'finished' else False
                    display = '%02d | %s%% | [B]%s[/B] | [I]%s [/I]' % (
                        count, str(progress), folder_str, name)
                    url_params = {
                        'mode': 'premiumize.pm_torrent_cloud',
                        'id': item['folder_id'],
                        'folder_name': normalize(item['name'])
                    }
                else:
                    is_folder = False
                    details = Premiumize.get_item_details(item['file_id'])
                    url_link = details['link']
                    if url_link.startswith('/'): url_link = 'https' + url_link
                    size = details['size']
                    display_size = float(int(size)) / 1073741824
                    display = '%02d | %s%% | [B]%s[/B] | %.2f GB | [I]%s [/I]' % (
                        count, str(progress), file_str, display_size, name)
                    url_params = {
                        'mode': 'media_play',
                        'url': url_link,
                        'media_type': 'video'
                    }
                    down_file_params = {
                        'mode': 'downloader',
                        'name': item['name'],
                        'url': url_link,
                        'db_type': 'cloud.premiumize',
                        'image': default_pm_icon
                    }
                    cm.append((down_str,
                               'RunPlugin(%s)' % build_url(down_file_params)))
                url = build_url(url_params)
                listitem = make_listitem()
                listitem.setLabel(display)
                listitem.addContextMenuItems(cm)
                listitem.setArt({
                    'icon': default_pm_icon,
                    'poster': default_pm_icon,
                    'thumb': default_pm_icon,
                    'fanart': fanart,
                    'banner': default_pm_icon
                })
                yield (url, listitem, is_folder)
            except:
                pass

    __handle__ = int(argv[1])
    extensions = supported_video_extensions()
    transfer_files = Premiumize.transfers_list()['transfers']
    folder_str, file_str, down_str = ls(32742).upper(), ls(32743).upper(), ls(
        32747)
    kodi_utils.add_items(__handle__, list(_builder()))
    kodi_utils.set_content(__handle__, 'files')
    kodi_utils.end_directory(__handle__)
    kodi_utils.set_view_mode('view.premium')