2021-10-02, 09:54
hi @M89SE
absolutly nice work...the guide is amazing
i have one wish if its possible to add a downloadinterval for xmlfile
like the funktion in tvgf/ivie
simular like this....or is there any option to set time for download xmlguide?
absolutly nice work...the guide is amazing
i have one wish if its possible to add a downloadinterval for xmlfile
like the funktion in tvgf/ivie
python:def fetchFile(self):
retVal = self.FETCH_NOT_NEEDED
fetch = False
if not os.path.exists(self.filePath): # always fetch if file doesn't exist!
fetch = True
else:
interval = int(self.addon.getSetting('xmltv.interval'))
if interval != self.INTERVAL_ALWAYS:
modTime = datetime.datetime.fromtimestamp(os.path.getmtime(self.filePath))
td = datetime.datetime.now() - modTime
# need to do it this way cause Android doesn't support .total_seconds()
diff = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10 ** 6) / 10 ** 6
if ((interval == self.INTERVAL_12 and diff >= 43200) or
(interval == self.INTERVAL_24 and diff >= 86400) or
(interval == self.INTERVAL_48 and diff >= 172800) or
(interval == self.INTERVAL_72 and diff >= 259200) or
(interval == self.INTERVAL_96 and diff >= 345600) or
(interval == self.INTERVAL_120 and diff >= 432000)):
fetch = True
else:
fetch = True
if fetch:
try:
os.remove(current_db)
except:
pass
tmpFile = os.path.join(self.basePath, 'tmp')
f = open(tmpFile, 'wb')
try:
if self.fileName == 'user.xml' and utils.get_setting(addon_id,'xmltv.type') == '9':
f.close()
try:os.remove(tmpFile)
except:pass
if grabber.xml_config() == 'Fetch OK':
retVal = self.FETCH_OK
else:
retVal = self.FETCH_ERROR
elif self.fileUrl == utils.get_setting(addon_id,'xmltv.url') and self.fileUrl.endswith('.zip'):
dp = xbmcgui.DialogProgress()
zipPath = translatePath(os.path.join('special://home', 'custom_tempfile.zip'))
zipurl = self.fileUrl
dp.create("iVue","Downloading guide data")
try:urlrequest.urlretrieve(zipurl,zipPath,lambda nb, bs, fs, url=zipurl: _pbhook(nb,bs,fs,zipurl,dp))
except:urllib.urlretrieve(zipurl,zipPath,lambda nb, bs, fs, url=zipurl: _pbhook(nb,bs,fs,zipurl,dp))
f.close()
elif self.fileUrl.endswith('.zip'):
dp = xbmcgui.DialogProgress()
zipPath = translatePath(os.path.join('special://home', 'tempfile.zip'))
zipurl = self.fileUrl
dp.create("iVue","Downloading guide data")
try:urlrequest.urlretrieve(zipurl,zipPath,lambda nb, bs, fs, url=zipurl: _pbhook(nb,bs,fs,zipurl,dp))
except:urllib.urlretrieve(zipurl,zipPath,lambda nb, bs, fs, url=zipurl: _pbhook(nb,bs,fs,zipurl,dp))
f.close()
else:
request = urlrequest.Request(self.fileUrl)
tmpData = urlrequest.urlopen(request)
data = tmpData.read()
if tmpData.info().get('content-encoding') == 'gzip':
data = zlib.decompress(data, zlib.MAX_WBITS + 16)
f.write(data)
f.close()
except errors as e:
if e.code == 401:
utils.notify(addon_id, 'Connection Error !!! Please Try Again')
else:
utils.notify(addon_id, e)
basePath = translatePath(os.path.join('special://profile', 'addon_data', 'script.ivueguide'))
zipPath = translatePath(os.path.join('special://home', 'tempfile.zip'))
customzipPath = translatePath(os.path.join('special://home', 'custom_tempfile.zip'))
tempzipPath = translatePath(os.path.join('special://profile', 'addon_data', 'script.ivueguide', 'custom_tempfile'))
customPath = translatePath(os.path.join('special://profile', 'addon_data', 'script.ivueguide', 'custom.xml'))
if os.path.exists(zipPath):
if os.path.exists(self.filePath):
os.remove(self.filePath)
os.remove(tmpFile)
tryhutil.unpack_archive(zipPath, basePath)
except:xbmc.executebuiltin("XBMC.Extract(%s, %s)" % ( zipPath.encode("utf-8"), basePath.encode("utf-8")), True)
os.remove(zipPath)
retVal = self.FETCH_OK
xbmc.log('[script.ivueguide] file %s was downloaded' % self.filePath, xbmc.LOGDEBUG)
if os.path.exists(customzipPath):
if os.path.exists(self.filePath):
os.remove(self.filePath)
os.remove(tmpFile)
tryhutil.unpack_archive(customzipPath, tempzipPath)
except:xbmc.executebuiltin("XBMC.Extract(%s, %s)" % ( customzipPath.encode("utf-8"), tempzipPath.encode("utf-8")), True)
for filename in os.listdir(tempzipPath):
if os.path.exists(customPath):
os.remove(customPath)
os.rename(os.path.join(tempzipPath, filename), customPath)
shutil.rmtree(tempzipPath)
os.remove(customzipPath)
retVal = self.FETCH_OK
xbmc.log('[script.ivueguide] file %s was downloaded' % self.filePath, xbmc.LOGDEBUG)
if os.path.exists(tmpFile):
if os.path.getsize(tmpFile) > 256:
if os.path.exists(self.filePath):
os.remove(self.filePath)
os.rename(tmpFile, self.filePath)
retVal = self.FETCH_OK
xbmc.log('[script.ivueguide] file %s was downloaded' % self.filePath, xbmc.LOGDEBUG)
else:
retVal = self.FETCH_ERROR
return retVal
simular like this....or is there any option to set time for download xmlguide?