本文整理汇总了Python中resources.lib.libraries.control.makeFile函数的典型用法代码示例。如果您正苦于以下问题:Python makeFile函数的具体用法?Python makeFile怎么用?Python makeFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了makeFile函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setSettings
def setSettings():
try:
control.makeFile(control.dataPath)
settingsFile = control.settingsFile
file = control.openFile(settingsFile)
read = file.read().splitlines()
file.close()
write = unicode("<settings>" + "\n", "UTF-8")
for line in read:
if len(re.findall("<settings>", line)) > 0:
continue
elif len(re.findall("</settings>", line)) > 0:
continue
write += unicode(line.rstrip() + "\n", "UTF-8")
if not 'id="droid"' in write:
write += unicode(' <setting id="droid" value="false" />' + "\n", "UTF-8")
write += unicode("</settings>" + "\n", "UTF-8")
file = control.openFile(settingsFile, "w")
file.write(str(write))
file.close()
except:
return
开发者ID:noba3,项目名称:KoTos,代码行数:27,代码来源:nhlcom.py
示例2: addView
def addView(content):
try:
skin = control.skin
skinPath = control.skinPath
xml = os.path.join(skinPath,'addon.xml')
file = control.openFile(xml)
read = file.read().replace('\n','')
file.close()
try: src = re.compile('defaultresolution="(.+?)"').findall(read)[0]
except: src = re.compile('<res.+?folder="(.+?)"').findall(read)[0]
src = os.path.join(skinPath, src)
src = os.path.join(src, 'MyVideoNav.xml')
file = control.openFile(src)
read = file.read().replace('\n','')
file.close()
views = re.compile('<views>(.+?)</views>').findall(read)[0]
views = [int(x) for x in views.split(',')]
for view in views:
label = control.infoLabel('Control.GetLabel(%s)' % (view))
if not (label == '' or label == None): break
record = (skin, content, str(view))
control.makeFile(control.dataPath)
dbcon = database.connect(control.databaseFile)
dbcur = dbcon.cursor()
dbcur.execute("CREATE TABLE IF NOT EXISTS views (""skin TEXT, ""view_type TEXT, ""view_id TEXT, ""UNIQUE(skin, view_type)"");")
dbcur.execute("DELETE FROM views WHERE skin = '%s' AND view_type = '%s'" % (record[0], record[1]))
dbcur.execute("INSERT INTO views Values (?, ?, ?)", record)
dbcon.commit()
viewName = control.infoLabel('Container.Viewmode')
control.infoDialog(control.lang(30491).encode('utf-8'), heading=viewName)
except:
return
开发者ID:mpie,项目名称:repo,代码行数:33,代码来源:views.py
示例3: addFavourite
def addFavourite(meta, content, query):
try:
item = dict()
meta = json.loads(meta)
imdb = item['imdb'] = meta['imdb']
if 'title' in meta: title = item['title'] = meta['title']
if 'tvshowtitle' in meta: title = item['title'] = meta['tvshowtitle']
if 'year' in meta: item['year'] = meta['year']
if 'poster' in meta: item['poster'] = meta['poster']
if 'fanart' in meta: item['fanart'] = meta['fanart']
if 'tmdb' in meta: item['tmdb'] = meta['tmdb']
if 'tvdb' in meta: item['tvdb'] = meta['tvdb']
if 'tvrage' in meta: item['tvrage'] = meta['tvrage']
control.makeFile(control.dataPath)
dbcon = database.connect(control.favouritesFile)
dbcur = dbcon.cursor()
dbcur.execute("CREATE TABLE IF NOT EXISTS %s (""id TEXT, ""items TEXT, ""UNIQUE(id)"");" % content)
dbcur.execute("DELETE FROM %s WHERE id = '%s'" % (content, imdb))
dbcur.execute("INSERT INTO %s Values (?, ?)" % content, (imdb, repr(item)))
dbcon.commit()
if query == None: control.refresh()
control.infoDialog(control.lang(30411).encode('utf-8'), heading=title)
except:
return
开发者ID:JRepoInd,项目名称:lambda-addons,代码行数:26,代码来源:favourites.py
示例4: timeout
def timeout(function, *args, **table):
try:
response = None
f = repr(function)
f = re.sub('.+\smethod\s|.+function\s|\sat\s.+|\sof\s.+', '', f)
a = hashlib.md5()
for i in args: a.update(str(i))
a = str(a.hexdigest())
except:
pass
try:
table = table['table']
except:
table = 'rel_list'
try:
control.makeFile(control.dataPath)
dbcon = database.connect(control.cacheFile)
dbcur = dbcon.cursor()
dbcur.execute("SELECT * FROM %s WHERE func = '%s' AND args = '%s'" % (table, f, a))
match = dbcur.fetchone()
return int(match[3])
except:
return
开发者ID:PsychoMC,项目名称:PsychoMC,代码行数:27,代码来源:cache.py
示例5: strmFile
def strmFile(self, i):
try:
name, title, year, imdb, tmdb = i['name'], i['title'], i['year'], i['imdb'], i['tmdb']
sysname, systitle = urllib.quote_plus(name), urllib.quote_plus(title)
transname = name.translate(None, '\/:*?"<>|').strip('.')
content = '%s?action=play&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s' % (sys.argv[0], sysname, systitle, year, imdb, tmdb)
control.makeFile(self.library_folder)
folder = os.path.join(self.library_folder, transname)
control.makeFile(folder)
try:
if not 'ftp://' in folder: raise Exception()
from ftplib import FTP
ftparg = re.compile('ftp://(.+?):(.+?)@(.+?):?(\d+)?/(.+/?)').findall(folder)
ftp = FTP(ftparg[0][2],ftparg[0][0],ftparg[0][1])
try: ftp.cwd(ftparg[0][4])
except: ftp.mkd(ftparg[0][4])
ftp.quit()
except:
pass
stream = os.path.join(folder, transname + '.strm')
file = control.openFile(stream, 'w')
file.write(str(content))
file.close()
except:
pass
开发者ID:8821kitkat,项目名称:officialrepo,代码行数:31,代码来源:libtools.py
示例6: getSources
def getSources(self, name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date):
sourceDict = []
for package, name, is_pkg in pkgutil.walk_packages(__path__): sourceDict.append((name, is_pkg))
sourceDict = [i[0] for i in sourceDict if i[1] == False]
content = 'movie' if tvshowtitle == None else 'episode'
if content == 'movie':
sourceDict = [i for i in sourceDict if i.endswith(('_mv', '_mv_tv'))]
try: sourceDict = [(i, control.setting(re.sub('_mv_tv$|_mv$|_tv$', '', i))) for i in sourceDict]
except: sourceDict = [(i, 'true') for i in sourceDict]
else:
sourceDict = [i for i in sourceDict if i.endswith(('_tv', '_mv_tv'))]
try: sourceDict = [(i, control.setting(re.sub('_mv_tv$|_mv$|_tv$', '', i) + '_tv')) for i in sourceDict]
except: sourceDict = [(i, 'true') for i in sourceDict]
global global_sources
global_sources = []
threads = []
control.makeFile(control.dataPath)
self.sourceFile = control.sourcescacheFile
sourceDict = [i[0] for i in sourceDict if i[1] == 'true']
if content == 'movie':
title = cleantitle.normalize(title)
for source in sourceDict: threads.append(workers.Thread(self.getMovieSource, title, year, imdb, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source()))
else:
tvshowtitle = cleantitle.normalize(tvshowtitle)
season, episode = alterepisode.alterepisode().get(imdb, tmdb, tvdb, tvrage, season, episode, alter, title, date)
for source in sourceDict: threads.append(workers.Thread(self.getEpisodeSource, title, year, imdb, tvdb, season, episode, tvshowtitle, date, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source()))
try: timeout = int(control.setting('sources_timeout_40'))
except: timeout = 40
[i.start() for i in threads]
#[i.join() for i in threads] ; self.sources = global_sources ; return self.sources
for i in range(0, timeout * 2):
is_alive = [x.is_alive() for x in threads]
if all(x == False for x in is_alive): break
time.sleep(0.5)
for i in range(0, 5 * 2):
is_alive = len([i for i in threads if i.is_alive() == True])
if is_alive < 10: break
time.sleep(0.5)
self.sources = global_sources
return self.sources
开发者ID:gsolanoalvarez,项目名称:hdfulltv,代码行数:59,代码来源:__init__.py
示例7: service
def service(self):
try:
control.makeFile(control.dataPath)
dbcon = database.connect(control.libcacheFile)
dbcur = dbcon.cursor()
dbcur.execute("CREATE TABLE IF NOT EXISTS service (""setting TEXT, ""value TEXT, ""UNIQUE(setting)"");")
dbcur.execute("SELECT * FROM service WHERE setting = 'last_run'")
fetch = dbcur.fetchone()
if fetch == None:
serviceProperty = "1970-01-01 23:59:00.000000"
dbcur.execute("INSERT INTO service Values (?, ?)", ('last_run', serviceProperty))
dbcon.commit()
else:
serviceProperty = str(fetch[1])
dbcon.close()
except:
try: return dbcon.close()
except: return
try: control.window.setProperty(self.property, serviceProperty)
except: return
while (not xbmc.abortRequested):
try:
serviceProperty = control.window.getProperty(self.property)
t1 = datetime.timedelta(hours=6)
t2 = datetime.datetime.strptime(serviceProperty, '%Y-%m-%d %H:%M:%S.%f')
t3 = datetime.datetime.now()
check = abs(t3 - t2) > t1
if check == False: raise Exception()
if (control.player.isPlaying() or control.condVisibility('Library.IsScanningVideo')): raise Exception()
serviceProperty = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
control.window.setProperty(self.property, serviceProperty)
try:
dbcon = database.connect(control.libcacheFile)
dbcur = dbcon.cursor()
dbcur.execute("CREATE TABLE IF NOT EXISTS service (""setting TEXT, ""value TEXT, ""UNIQUE(setting)"");")
dbcur.execute("DELETE FROM service WHERE setting = 'last_run'")
dbcur.execute("INSERT INTO service Values (?, ?)", ('last_run', serviceProperty))
dbcon.commit()
dbcon.close()
except:
try: dbcon.close()
except: pass
if not control.setting('service_update') == 'true': raise Exception()
info = control.setting('service_notification') or 'true'
self.update(None, info=info)
except:
pass
control.sleep(10000)
开发者ID:8821kitkat,项目名称:officialrepo,代码行数:58,代码来源:libtools.py
示例8: get
def get(function, timeout, *args, **table):
try:
response = None
f = repr(function)
f = re.sub('.+\smethod\s|.+function\s|\sat\s.+|\sof\s.+', '', f)
a = hashlib.md5()
for i in args: a.update(str(i))
a = str(a.hexdigest())
except:
pass
try:
table = table['table']
except:
table = 'rel_list'
try:
control.makeFile(control.dataPath)
dbcon = database.connect(control.cacheFile)
dbcur = dbcon.cursor()
dbcur.execute("SELECT * FROM %s WHERE func = '%s' AND args = '%s'" % (table, f, a))
match = dbcur.fetchone()
response = eval(match[2].encode('utf-8'))
t1 = int(match[3])
t2 = int(time.time())
update = (abs(t2 - t1) / 3600) >= int(timeout)
if update == False:
return response
except:
pass
try:
r = function(*args)
if (r == None or r == []) and not response == None:
return response
elif (r == None or r == []):
return r
except:
return
try:
r = repr(r)
t = int(time.time())
dbcur.execute("CREATE TABLE IF NOT EXISTS %s (""func TEXT, ""args TEXT, ""response TEXT, ""added TEXT, ""UNIQUE(func, args)"");" % table)
dbcur.execute("DELETE FROM %s WHERE func = '%s' AND args = '%s'" % (table, f, a))
dbcur.execute("INSERT INTO %s Values (?, ?, ?, ?)" % table, (f, a, r, t))
dbcon.commit()
except:
pass
try:
return eval(r.encode('utf-8'))
except:
pass
开发者ID:macblizzard,项目名称:aftershock-repo,代码行数:58,代码来源:cache.py
示例9: checkSources
def checkSources(self, name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date):
sourceDict = []
for package, name, is_pkg in pkgutil.walk_packages(__path__): sourceDict.append((name, is_pkg))
sourceDict = [i[0] for i in sourceDict if i[1] == False]
content = 'movie' if tvshowtitle == None else 'episode'
if content == 'movie':
sourceDict = [i for i in sourceDict if i.endswith(('_mv', '_mv_tv'))]
try: sourceDict = [(i, control.setting(re.sub('_mv_tv$|_mv$|_tv$', '', i))) for i in sourceDict]
except: sourceDict = [(i, 'true') for i in sourceDict]
else:
sourceDict = [i for i in sourceDict if i.endswith(('_tv', '_mv_tv'))]
try: sourceDict = [(i, control.setting(re.sub('_mv_tv$|_mv$|_tv$', '', i) + '_tv')) for i in sourceDict]
except: sourceDict = [(i, 'true') for i in sourceDict]
threads = []
control.makeFile(control.dataPath)
self.sourceFile = control.sourcescacheFile
sourceDict = [i[0] for i in sourceDict if i[1] == 'true']
if content == 'movie':
title = cleantitle.normalize(title)
for source in sourceDict: threads.append(workers.Thread(self.getMovieSource, title, year, imdb, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source()))
else:
tvshowtitle = cleantitle.normalize(tvshowtitle)
season, episode = alterepisode.alterepisode().get(imdb, tmdb, tvdb, tvrage, season, episode, alter, title, date)
for source in sourceDict:
#control.log("SOURCE S2 %s" % source)
threads.append(workers.Thread(self.getEpisodeSource, title, year, imdb, tvdb, season, episode, tvshowtitle, date, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source()))
try: timeout = int(control.setting('sources_timeout_40'))
except: timeout = 40
[i.start() for i in threads]
for i in range(0, timeout * 2):
try:
if xbmc.abortRequested == True: return sys.exit()
if len(self.sources) >= 10: break
is_alive = [x.is_alive() for x in threads]
if all(x == False for x in is_alive): break
time.sleep(0.5)
except:
pass
if len(self.sources) >= 10: return True
else: return False
开发者ID:msousinha,项目名称:myhome-repository,代码行数:54,代码来源:__init__.py
示例10: deleteBookmark
def deleteBookmark(name, imdb='0'):
try:
idFile = hashlib.md5()
for i in name: idFile.update(str(i))
for i in imdb: idFile.update(str(i))
idFile = str(idFile.hexdigest())
control.makeFile(control.dataPath)
dbcon = database.connect(control.databaseFile)
dbcur = dbcon.cursor()
dbcur.execute("CREATE TABLE IF NOT EXISTS bookmark (""idFile TEXT, ""timeInSeconds TEXT, ""UNIQUE(idFile)"");")
dbcur.execute("DELETE FROM bookmark WHERE idFile = '%s'" % idFile)
dbcon.commit()
except:
pass
开发者ID:bialagary,项目名称:mw,代码行数:14,代码来源:bookmarks.py
示例11: clearSources
def clearSources(self):
try:
yes = control.yesnoDialog(control.lang(30510).encode('utf-8'), '', '')
if not yes: return
control.makeFile(control.dataPath)
dbcon = database.connect(control.sourcescacheFile)
dbcur = dbcon.cursor()
dbcur.execute("DROP TABLE IF EXISTS rel_src")
dbcur.execute("VACUUM")
dbcon.commit()
control.infoDialog(control.lang(30511).encode('utf-8'))
except:
pass
开发者ID:gsolanoalvarez,项目名称:hdfulltv,代码行数:15,代码来源:__init__.py
示例12: fetchImdb
def fetchImdb(items):
try:
control.makeFile(control.dataPath)
dbcon = database.connect(control.metacacheFile)
dbcur = dbcon.cursor()
for i in range(0, len(items)):
try:
dbcur.execute("SELECT imdb, tmdb FROM meta_imdb WHERE (title = '%s')" % (items[i]['title']))
item = dbcur.fetchone()
try :items[i].update({'imdb':item[0], 'tmdb': item[1]})
except: pass
except:
pass
dbcur.close()
dbcon.close()
except:
pass
return items
开发者ID:kevintone,项目名称:tdbaddon,代码行数:19,代码来源:metacache.py
示例13: insert
def insert(meta):
try:
control.makeFile(control.dataPath)
dbcon = database.connect(control.metacacheFile)
dbcur = dbcon.cursor()
dbcur.execute("CREATE TABLE IF NOT EXISTS meta (""imdb TEXT, ""tmdb TEXT, ""tvdb TEXT, ""lang TEXT, ""item TEXT, ""time TEXT, ""UNIQUE(imdb, tmdb, tvdb, lang)"");")
t = int(time.time())
for m in meta:
try:
i = repr(m['item'])
try: dbcur.execute("DELETE * FROM meta WHERE (imdb = '%s' and lang = '%s' and not imdb = '0') or (tmdb = '%s' and lang = '%s' and not tmdb = '0') or (tvdb = '%s' and lang = '%s' and not tvdb = '0')" % (m['imdb'], m['lang'], m['tmdb'], m['lang'], m['tvdb'], m['lang']))
except: pass
dbcur.execute("INSERT INTO meta Values (?, ?, ?, ?, ?, ?)", (m['imdb'], m['tmdb'], m['tvdb'], m['lang'], i, t))
except:
pass
dbcon.commit()
except:
return
开发者ID:gitrazr,项目名称:filmkodi,代码行数:19,代码来源:metacache.py
示例14: strmFile
def strmFile(self, i):
try:
name, title, year, imdb, tmdb = i["name"], i["title"], i["year"], i["imdb"], i["tmdb"]
sysname, systitle = urllib.quote_plus(name), urllib.quote_plus(title)
transname = name.translate(None, '\/:*?"<>|').strip(".")
content = "%s?action=play&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s" % (
sys.argv[0],
sysname,
systitle,
year,
imdb,
tmdb,
)
control.makeFile(self.library_folder)
folder = os.path.join(self.library_folder, transname)
control.makeFile(folder)
try:
if not "ftp://" in folder:
raise Exception()
from ftplib import FTP
ftparg = re.compile("ftp://(.+?):(.+?)@(.+?):?(\d+)?/(.+/?)").findall(folder)
ftp = FTP(ftparg[0][2], ftparg[0][0], ftparg[0][1])
try:
ftp.cwd(ftparg[0][4])
except:
ftp.mkd(ftparg[0][4])
ftp.quit()
except:
pass
stream = os.path.join(folder, transname + ".strm")
file = control.openFile(stream, "w")
file.write(str(content))
file.close()
except:
pass
开发者ID:cuongnvth,项目名称:hieuhien.vn,代码行数:42,代码来源:libtools.py
示例15: insertImdb
def insertImdb(items):
try :
control.makeFile(control.dataPath)
dbcon = database.connect(control.metacacheFile)
dbcur = dbcon.cursor()
dbcur.execute("CREATE TABLE IF NOT EXISTS meta_imdb ("" title TEXT, ""imdb TEXT, ""tmdb TEXT, ""time TEXT,""UNIQUE(imdb, tmdb, title)"");")
t = int(time.time())
for item in items:
if not item['imdb'] == '0' or not item['tmdb'] == '0':
try:
try: dbcur.execute("DELETE FROM meta_imdb WHERE title = '%s'" % (item['title']))
except:
pass
dbcur.execute("INSERT INTO meta_imdb Values (?, ?, ?, ?)", (item['title'], item['imdb'], item['tmdb'], t))
except:
pass
dbcon.commit()
except:
return
开发者ID:kevintone,项目名称:tdbaddon,代码行数:20,代码来源:metacache.py
示例16: addBookmark
def addBookmark(currentTime, name, imdb="0"):
try:
idFile = hashlib.md5()
for i in name:
idFile.update(str(i))
for i in imdb:
idFile.update(str(i))
idFile = str(idFile.hexdigest())
timeInSeconds = str(currentTime)
control.makeFile(control.dataPath)
dbcon = database.connect(control.databaseFile)
dbcur = dbcon.cursor()
dbcur.execute(
"CREATE TABLE IF NOT EXISTS bookmark (" "idFile TEXT, " "timeInSeconds TEXT, " "UNIQUE(idFile)" ");"
)
dbcur.execute("DELETE FROM bookmark WHERE idFile = '%s'" % idFile)
dbcur.execute("INSERT INTO bookmark Values (?, ?)", (idFile, timeInSeconds))
dbcon.commit()
except:
pass
开发者ID:AMObox,项目名称:teammaniac,代码行数:20,代码来源:bookmarks.py
示例17: strmFile
def strmFile(self, i):
try:
name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date = i['name'], i['title'], i['year'], i['imdb'], i['tmdb'], i['tvdb'], i['tvrage'], i['season'], i['episode'], i['tvshowtitle'], i['alter'], i['date']
episodename, episodetitle = urllib.quote_plus(name), urllib.quote_plus(title)
systitle, syspremiered = urllib.quote_plus(tvshowtitle), urllib.quote_plus(date)
if self.version >= 15:
transname = '%s (%s) S%02dE%02d' % (tvshowtitle.translate(None, '\/:*?"<>|'), year, int(season), int(episode))
transtitle = '%s (%s)' % (tvshowtitle.translate(None, '\/:*?"<>|'), year)
else:
transname = name.translate(None, '\/:*?"<>|').strip('.')
transtitle = tvshowtitle.translate(None, '\/:*?"<>|').strip('.')
transseason = 'Season %s' % season.translate(None, '\/:*?"<>|').strip('.')
content = '%s?action=play&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s&season=%s&episode=%s&tvshowtitle=%s&alter=%s&date=%s' % (sys.argv[0], episodename, episodetitle, year, imdb, tmdb, tvdb, tvrage, season, episode, systitle, alter, syspremiered)
control.makeFile(self.library_folder)
folder = os.path.join(self.library_folder, transtitle)
control.makeFile(folder)
try:
if not 'ftp://' in folder: raise Exception()
from ftplib import FTP
ftparg = re.compile('ftp://(.+?):(.+?)@(.+?):?(\d+)?/(.+/?)').findall(folder)
ftp = FTP(ftparg[0][2],ftparg[0][0],ftparg[0][1])
try: ftp.cwd(ftparg[0][4])
except: ftp.mkd(ftparg[0][4])
ftp.quit()
except:
pass
folder = os.path.join(folder, transseason)
control.makeFile(folder)
try:
if not 'ftp://' in folder: raise Exception()
from ftplib import FTP
ftparg = re.compile('ftp://(.+?):(.+?)@(.+?):?(\d+)?/(.+/?)').findall(folder)
ftp = FTP(ftparg[0][2],ftparg[0][0],ftparg[0][1])
try: ftp.cwd(ftparg[0][4])
except: ftp.mkd(ftparg[0][4])
ftp.quit()
except:
pass
stream = os.path.join(folder, transname + '.strm')
file = control.openFile(stream, 'w')
file.write(str(content))
file.close()
except:
pass
开发者ID:rrosajp,项目名称:filmkodi,代码行数:54,代码来源:libtools.py
示例18: run
def run(self):
def download(): return []
result = cache.get(download, 600000000, table='rel_dl')
for item in result:
self.name = item['name'] ; self.image = item['image'] ; self.url = item['url']
sysname = self.name.translate(None, '\/:*?"<>|').strip('.')
url = self.url.split('|')[0]
try: headers = dict(urlparse.parse_qsl(self.url.rsplit('|', 1)[1]))
except: headers = dict('')
ext = os.path.splitext(urlparse.urlparse(url).path)[1][1:].lower()
if not ext in ['mp4', 'mkv', 'flv', 'avi', 'mpg']: ext = 'mp4'
hdlr = re.compile('.+? ([(]\d{4}[)]|S\d*E\d*)$').findall(self.name)
if len(hdlr) == 0: self.content = 'Uncategorised'
hdlr = re.compile('.+? (S\d*E\d*)$').findall(self.name)
if len(hdlr) > 0: self.content = 'TVShows'
hdlr = re.compile('.+? [(](\d{4})[)]$').findall(self.name)
if len(hdlr) > 0: self.content = 'Movies'
if self.content == 'Movies':
dest = os.path.join(downloadPath, 'Movies')
control.makeFile(dest)
dest = os.path.join(dest, sysname)
control.makeFile(dest)
elif self.content == 'TVShows':
d = re.compile('(.+?) S(\d*)E(\d*)$').findall(sysname)[0]
dest = os.path.join(downloadPath, 'TV Shows')
control.makeFile(dest)
dest = os.path.join(dest, d[0])
control.makeFile(dest)
dest = os.path.join(dest, 'Season %01d' % int(d[1]))
control.makeFile(dest)
else:
dest = os.path.join(downloadPath, 'Uncategorised')
control.makeFile(dest)
dest = os.path.join(dest, sysname + '.' + ext)
control.infoDialog(self.name + ' Is Downloading', 'Downloads Started', self.image, time=7000)
try:
req = urllib2.Request(url, headers=headers)
resp = urllib2.urlopen(req, timeout=30)
except Exception,e:
removeDownload(self.url)
print '%s ERROR - File Failed To Open' % (dest)
continue
try: self.size = int(resp.headers['Content-Length'])
except: self.size = 0
if self.size < 1:
removeDownload(self.url)
print '%s Unknown filesize - Unable to download' % (dest)
continue
try: resumable = 'bytes' in resp.headers['Accept-Ranges'].lower()
except: resumable = False
size = 1024 * 1024
if self.size < size: size = self.size
gb = '%.2f GB' % (float(self.size) / 1073741824)
start = time.clock()
total = 0 ; notify = 0 ; errors = 0 ; count = 0 ; resume = 0 ; sleep = 0
self.clear()
control.window.setProperty(property + '.status', 'downloading')
control.window.setProperty(property + '.name', str(self.name))
control.window.setProperty(property + '.image', str(self.image))
control.window.setProperty(property + '.size', str(gb))
f = control.openFile(dest, 'wb')
chunk = None
chunks = []
while True:
downloaded = total
for c in chunks:
downloaded += len(c)
percent = min(100 * downloaded / self.size, 100)
self.speed = str(int((downloaded / 1024) / (time.clock() - start))) + ' KB/s'
self.percent = str(percent) + '%'
#.........这里部分代码省略.........
开发者ID:8821kitkat,项目名称:officialrepo,代码行数:101,代码来源:downloader.py
示例19: resolve
def resolve(self, url):
try:
m3u8 = [
'#EXTM3U',
'#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",DEFAULT=YES,AUTOSELECT=YES,NAME="Stream 1",URI="{audio_stream}"',
'',
'#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=0,NAME="{stream_name}",AUDIO="audio"',
'{video_stream}'
]
query = urlparse.parse_qs(url)
query = dict([(key, query[key][0]) if query[key] else (key, '') for key in query])
auth = 'http://streamtorrent.tv/api/torrent/%s/%s.m3u8?json=true' % (query['vid_id'], query['stream_id'])
r = client.request(auth)
r = json.loads(r)
try: url = r['url']
except: url = None
if not url == None:
def dialog(url):
try: self.disableScraper = control.yesnoDialog('To watch this video visit from any device', '[COLOR skyblue]%s[/COLOR]' % url, '', 'Torba', 'Cancel', 'Settings')
except: pass
workers.Thread(dialog, url).start()
control.sleep(3000)
for i in range(100):
try:
if not control.condVisibility('Window.IsActive(yesnoDialog)'): break
r = client.request(auth)
r = json.loads(r)
try: url = r['url']
except: url = None
if url == None: break
workers.Thread(dialog, url).start()
control.sleep(3000)
except:
pass
if self.disableScraper:
control.openSettings(query='2.0')
return ''
control.execute('Dialog.Close(yesnoDialog)')
if not url == None: return
stream_name = '%sp' % (query['height'])
video_stream = r[stream_name]
if not 'audio' in r: return video_stream
audio_stream = r['audio']
content = ('\n'.join(m3u8)).format(**{'audio_stream': audio_stream, 'stream_name': stream_name, 'video_stream': video_stream})
path = os.path.join(control.dataPath, 'torbase.m3u8')
control.makeFile(control.dataPath) ; control.deleteFile(path)
file = control.openFile(path, 'w') ; file.write(content) ; file.close()
return path
except:
return
开发者ID:mpie,项目名称:repo,代码行数:76,代码来源:torba_mv_tv_null.py
示例20: _get_connection
def _get_connection():
control.makeFile(control.dataPath)
conn = db.connect(control.cacheFile)
conn.row_factory = _dict_factory
return conn
开发者ID:mpie,项目名称:repo,代码行数:5,代码来源:cache.py
注:本文中的resources.lib.libraries.control.makeFile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论