def addDownload(name, url, image, provider=None): try: def download(): return [] result = cache.get(download, 600000000, table='rel_dl') result = [i['name'] for i in result] except: pass if name in result: return control.infoDialog('Item Already In Your Queue', name) from resources.lib.indexers import streamhub url = streamhub.resolver().link(url) if url == None: return try: u = url.split('|')[0] try: headers = dict(urlparse.parse_qsl(url.rsplit('|', 1)[1])) except: headers = dict('') ext = os.path.splitext(urlparse.urlparse(u).path)[1][1:].lower() if ext == 'm3u8': raise Exception() if not ext in ['mp4', 'm4a', 'mp3', 'aac', 'mkv', 'flv', 'avi', 'mpg']: ext = 'mp4' dest = name + '.' + ext req = urllib2.Request(u, headers=headers) resp = urllib2.urlopen(req, timeout=30) size = int(resp.headers['Content-Length']) size = ' %.2f GB' % (float(size) / 1073741824) no = control.yesnoDialog(dest, 'Complete file is' + size, 'Continue with download?', name + ' - ' + 'Confirm Download', 'Confirm', 'Cancel') if no: return except: return control.infoDialog('Unable to download') pass def download(): return [{'name': name, 'url': url, 'image': image}] result = cache.get(download, 600000000, table='rel_dl') result = [i for i in result if not i['url'] == url] def download(): return result + [{'name': name, 'url': url, 'image': image}] result = cache.get(download, 0, table='rel_dl') control.infoDialog('Item Added to Queue', name)
elif action == 'tvtuner': from resources.lib.indexers import streamhub streamhub.indexer().tvtuner(url) elif 'youtube' in str(action): from resources.lib.indexers import streamhub streamhub.indexer().youtube(url, action) elif action == 'play': from resources.lib.indexers import streamhub streamhub.player().play(url, content) elif action == 'browser': from resources.lib.indexers import streamhub streamhub.resolver().browser(url) elif action == 'search': from resources.lib.indexers import streamhub streamhub.indexer().search() elif action == 'addSearch': from resources.lib.indexers import streamhub streamhub.indexer().addSearch(url) elif action == 'delSearch': from resources.lib.indexers import streamhub streamhub.indexer().delSearch() elif action == 'queueItem': from resources.lib.modules import control