Kodi Community Forum

Full Version: m-TVGuide
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
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 
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() Sad
                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)
                tryConfusedhutil.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)
                tryConfusedhutil.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?
@Kangool I will add in in future version.
(2021-10-02, 10:01)M89SE Wrote: [ -> ]@Kangool I will add in in future version.

nice....thanks
(2021-10-01, 11:53)M89SE Wrote: [ -> ]
(2021-10-01, 11:32)Werner Wrote: [ -> ]that was quick Smile thanks for the answer, so just that i understand it, when my guide.xml doesn't have new epg, only then it will download new file, hmm ok so on day 3 i can't look for next day to add timers, so i need to wait that a new guide gets downloaded, i will test this out, best for me would be that it just downloads the guide when it is older then 24h. So i would see always at worst the next 2 days. Anyway great work, thanks

I will see what I can do. Smile
Thanks, i tried what you told me, but that will not work for me, i changed my guide now to 1 day and create it 2 times a day and download the guide everytime when i open m-TVGuide, that lowers the traffic, but it is not really a good solution for a long time. Would be really nice to see this feature sooner then later in your guide, else i will need to write script which downloads the guide locally  Wink
@Werner  @Kangool Try out v52, created a similar function to that in TVGF. but I haven't tested it out yet so not entirely sure if its working.
https://github.com/Mariusz89B/script.mtv.../9.6.2_v51

Settings -> EPG -> EPG update interval

EDIT: 
Made a mistake, I will soon post a corrected version.

EDIT2: 
https://github.com/Mariusz89B/script.mtv.../9.6.2_v53
Wow awesome, looked in your code and its exactly what i wanted 12h,24h,48h,7d,14d is perfect. I will test it out later when i have time.

If you have a link where i could send you some Thank you, then let me know, really awesome your work  Blush
(2021-10-02, 12:11)Werner Wrote: [ -> ]Wow awesome, looked in your code and its exactly what i wanted 12h,24h,48h,7d,14d is perfect. I will test it out later when i have time.

If you have a link where i could send you some Thank you, then let me know, really awesome your work  Blush

A small correction in 9.6.2_v53.
(2021-10-02, 12:13)M89SE Wrote: [ -> ]
(2021-10-02, 12:11)Werner Wrote: [ -> ]Wow awesome, looked in your code and its exactly what i wanted 12h,24h,48h,7d,14d is perfect. I will test it out later when i have time.

If you have a link where i could send you some Thank you, then let me know, really awesome your work  Blush

A small correction in 9.6.2_v53.

you are my hero ggg
(2021-10-02, 08:02)M89SE Wrote: [ -> ]
(2021-10-01, 23:24)Dimension Wrote: [ -> ]
(2021-10-01, 23:20)M89SE Wrote: [ -> ]Ok, I will run some tests tomorrow, maybe I need to correct something for file reading.

Just to be clear, the epg you provided is in xmltv format?

Yes, I am using the xmltv link provided by m34u's website.
Thanks for looking into this.

I suspect the epg is not cooperating with the addon, could you send me this epg or a fragment of it on PM and I will see if I need to add support for it?

The first rows of the EPG should look like this:

xml:
<?xml version="1.0" encoding="UTF-8"?>
<tv generator-info-name="WebGrab+Plus/w MDB & REX Postprocess -- version V2.1.5 -- Jan van Straaten" generator-info-url="http://www.webgrabplus.com">
  <channel id="SVT1 SE">
    <display-name lang="sv">SVT1 SE</display-name>
    <icon src="http://m-tvguide.pl/ikony/SE/22.06.2021/svt1_se.png" />
    <url>http://www.tv.nu</url>
  </channel>

EDIT:
Are there any strange characters in the epg that might call an utf-8 decode error?

My EPG does not look like that at all. I assume the reasoning why is because I am downloading the xmltv file directly from m34u's website. If I download their "no compression" file it looks like that but that is an xml file and not xmltv.
PM sent.
@Dimension Try this version, the addon should now be able to load locally stored .zip, .xml.gz and .bz2 files:
https://github.com/Mariusz89B/script.mtv.../9.6.2_v58

@Werner @Kangool I also added option update EPG on every start.
its not woriking with the time to download epg
if i set intervall to every start and i switch between categories than epg downloaded evry switch
also it downloads epg but not aktualizise the programdata
sorry epg loads correct my kollege change some settings so he create only 24h epg at 5am
but the failure while switching between categories is actual
but only if you have intervall on every start
(2021-10-03, 05:06)Kangool Wrote: [ -> ]sorry epg loads correct my kollege change some settings so he create only 24h epg at 5am
but the failure while switching between categories is actual
but only if you have intervall on every start

@Kangool Fixed category switch:
https://github.com/Mariusz89B/script.mtv.../9.6.2_v58

EDIT:
In my opinion the add-on seems to be stable enough to be added to our repository, I only need a OK from @Dimension about loading local epg files and if EPG interval is working as supposed @Kangool @Werner .
(2021-10-03, 08:03)M89SE Wrote: [ -> ]
(2021-10-03, 05:06)Kangool Wrote: [ -> ]sorry epg loads correct my kollege change some settings so he create only 24h epg at 5am
but the failure while switching between categories is actual
but only if you have intervall on every start

@Kangool Fixed category switch:
https://github.com/Mariusz89B/script.mtv.../9.6.2_v58

EDIT:
In my opinion the add-on seems to be stable enough to be added to our repository, I only need a OK from @Dimension about loading local epg files and if EPG interval is working as supposed @Kangool @Werner .
Looks like everything is working other than not all of my channels are showing up but I think that is a problem in my settings. The guide is now pulling up and does show what is currently playing.
@Dimension Check if the channel names in your playlist are matching channel ids in EPG. You could also try to enable detection of alternative channel names.
https://github.com/Mariusz89B/script.mtv...splay_name

If you like to manually add streams to missing channels, then disable "Show only programs with streams assigned", then all channels in EPG will be visible.
https://github.com/Mariusz89B/script.mtv...oupdatecid
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14