Example #1
0
def MAINSIDE(cacheOnly = False):
    import time
    import datetime
    cached_path = os.path.join(os.path.join(main.datapath,'Cache'), 'Sidereel')
    cached = main.getFile(cached_path)
    if (not cached or (cached and time.mktime(datetime.date.today().timetuple()) > os.stat(cached_path).st_mtime)
         or xbmcgui.Window(10000).getProperty('Refresh_Sidreel')):
        from t0mm0.common.net import Net as net
        setCookie(MAINURL)
        response = net().http_GET(MAINURL)
        link = response.content
        link = cleanHex(link)
        link=link.replace('\r','').replace('\n','').replace('\t','').replace(' ','').replace('  ','')
        today=re.compile("<li class='current'>[^/]+?<h2 class='[^']*?'><span>(.+?)</span></h2><div(.+?)/div></div></li>",re.DOTALL).findall(link)
        match=re.compile("<li class=''>[^/]+?<h2 class='[^']+?'><span>(.+?)</span></h2><div(.+?)/div></div></li>",re.DOTALL).findall(link)
        match = today + match
        if match:
            main.setFile(cached_path,str(match),True)
        if '''<h3 class='sr-header sr-blue font-16'>Login to your account</h3>''' in link:
            main.addLink('[COLOR red]Login Error Clear Cache & Cookies Below[/COLOR]','TV','')
            main.addDir('[COLOR blue]Clear Cache & Cookies[/COLOR]','MashCache',416,art+'/maintenance.png')
        xbmcgui.Window(10000).clearProperty('Refresh_Sidreel')
    else: match = eval(cached)
    if cacheOnly: return False
    main.GA("None","SideReel")
    main.addDir('Search for Shows','TV',398,art+'/search.png')
    main.addDir('All Tracked Shows','TV',402,art+'/sidereel.png')
    
    import calendar
    todaytimestamp = calendar.timegm(time.strptime(time.strftime("%b") + " " + time.strftime("%d"), "%b %d"))
    showsdisplayed = 0
    for date,shows in match:
        print shows
        if 'data-track-label="Profile"' in shows:
            s = re.sub('(?i)^.*?,(.*)$','\\1',date).strip()
            timestamp =  calendar.timegm(time.strptime(s, "%b %d"))
            days = (timestamp - todaytimestamp) / 86400
            relative = getRelativeDate(days)
            main.addLink('[COLOR yellow]'+date+'[/COLOR]  [COLOR orange]('+relative+')[/COLOR]','',art+'/link.png')
            
            match2=re.compile("""data-track-label="Profile" href=".+?">([^<]+?)</a><div><a class=".+?data-track-label="Profile" href="([^"]+?)">([^<]+?)</a></div>""",re.DOTALL).findall(shows)
            for showname,seaepi, epiname in match2:
                se=re.search('season-(\d+)/episode-(\d+)',seaepi)
                if se:
                    if len(se.group(1))==1:
                        sea='0'+str(se.group(1))
                    else:
                        sea=str(se.group(1))
                    if len(se.group(2))==1:
                        epi='0'+str(se.group(2))
                    else:
                        epi=str(se.group(2))
                    final= 'S'+sea+'E'+epi
                else:
                    final=''

                main.addDir(showname+' '+final+' [COLOR red] "'+epiname+'"[/COLOR]','TV',20,art+'/sidereel.png')
                showsdisplayed += 1
    if not showsdisplayed: main.removeFile(cached_path)
Example #2
0
def showList(cacheOnly = False):
    if not user:
        xbmc.executebuiltin("XBMC.Notification(Sorry,Set Trakt user in settings,3000)")
        xbmcplugin.endOfDirectory(int(sys.argv[1]), False, False, False)
        return False
    import time,datetime,calendar
    todaytimestamp = calendar.timegm(time.strptime(time.strftime("%Y") + "-" + time.strftime("%m") + "-" + time.strftime("%d"), "%Y-%m-%d"))
    cached_path = os.path.join(os.path.join(main.datapath,'Cache'), 'Trakt')
    cached = main.getFile(cached_path)
    if (not cached or (cached and time.mktime(datetime.date.today().timetuple()) > os.stat(cached_path).st_mtime)
         or xbmcgui.Window(10000).getProperty('Refresh_Trakt')):
        setCookie()
        import hashlib,json
        data = {'username':user,'password':hashlib.sha1(passw).hexdigest()}
        link = main.OPENURL("http://api.trakt.tv/user/calendar/shows.json/"+TRAKT_API+"/"+user+'/6daysago/14',data=data)
        fields=json.loads(link)
        tofront = []
        daysinfuture = 2
        daysinpast = 1
        for item in fields:
            timestamp =  calendar.timegm(time.strptime(item['date'], "%Y-%m-%d"))
            if timestamp <= todaytimestamp + daysinfuture * 86400 and timestamp >= todaytimestamp - daysinpast * 86400:
                tofront.append(item)
        for item in tofront:fields.remove(item)
        fields = tofront + fields
        if fields:
            main.setFile(cached_path,str(fields),True)
        xbmcgui.Window(10000).clearProperty('Refresh_Trakt')
    else: fields = eval(cached)
    if cacheOnly: return False
    main.GA("None","Trakt")
    main.addDir('Search for Shows','TV',430,art+'/search.png')
    main.addDir('All Tracked Shows','TV',431,art+'/sidereel.png')
    showsdisplayed = 0
    for data in fields:
        timestamp =  calendar.timegm(time.strptime(data['date'], "%Y-%m-%d"))
        datestring = datetime.datetime.fromtimestamp(timestamp).strftime('%A, %b %d')
        days = (timestamp - todaytimestamp) / 86400
        relative = getRelativeDate(days)
        main.addLink('[COLOR yellow]'+datestring+'[/COLOR]  [COLOR orange]('+relative+')[/COLOR]','',art+'/link.png')
        for showdata in data['episodes']:
            if showdata['episode']['season'] < 10: sea='0'+str(showdata['episode']['season'])
            else: sea=str(showdata['episode']['season'])
            if showdata['episode']['number'] < 10: epi='0'+str(showdata['episode']['number'])
            else: epi=str(showdata['episode']['number'])
            episodenumber= 'S'+sea+'E'+epi
            airtime = showdata['show']['air_time_localized'].upper().replace("AM"," AM").replace("PM"," PM")+' on ' + showdata['show']['network']
            main.addDir(showdata['show']['title'].encode('utf-8')+' '+episodenumber+' [COLOR red]"'+showdata['episode']['title'].encode('utf-8')+
                        '"[/COLOR] [COLOR blue]'+ airtime.encode('utf-8') +'[/COLOR]','TV',20,showdata['show']['images']['poster'].encode('utf-8'),
                        showdata['episode']['overview'].encode('utf-8'),showdata['episode']['images']['screen'].encode('utf-8'))
            showsdisplayed += 1
    if not showsdisplayed: main.removeFile(cached_path)
Example #3
0
File: trakt.py Project: noba3/KoTos
def showList(cacheOnly = False):
    if not user:
        xbmc.executebuiltin("XBMC.Notification(Sorry,Set Trakt user in settings,3000)")
        xbmcplugin.endOfDirectory(int(sys.argv[1]), False, False, False)
        return False
    import time,datetime,calendar
    todaytimestamp = time.mktime(time.strptime(time.strftime("%Y") + "-" + time.strftime("%m") + "-" + time.strftime("%d"), "%Y-%m-%d"))
    cached_path = os.path.join(os.path.join(main.datapath,'Cache'), 'Trakt')
    cached = main.getFile(cached_path)
    if (not cached or (cached and time.mktime(datetime.date.today().timetuple()) > os.stat(cached_path).st_mtime)
         or xbmcgui.Window(10000).getProperty('Refresh_Trakt')):
        setCookie()
        import hashlib,json
        data = {'username':user,'password':hashlib.sha1(passw).hexdigest()}
        link = main.OPENURL("http://api.trakt.tv/user/calendar/shows.json/"+TRAKT_API+"/"+user+'/6daysago/14',data=data)
        fields=json.loads(link)
        tofront = []
        daysinfuture = 2
        daysinpast = 1
        for item in fields:
            timestamp =  time.mktime(time.strptime(item['date'], "%Y-%m-%d"))
            if timestamp <= todaytimestamp + daysinfuture * 86400 and timestamp >= todaytimestamp - daysinpast * 86400:
                tofront.append(item)
        for item in tofront:fields.remove(item)
        fields = tofront + fields
        if fields:
            main.setFile(cached_path,str(fields),True)
        xbmcgui.Window(10000).clearProperty('Refresh_Trakt')
    else: fields = eval(cached)
    if cacheOnly: return False
    main.GA("None","Trakt")
    main.addDir('Search for Shows','TV',430,art+'/search.png')
    main.addDir('All Tracked Shows','TV',431,art+'/sidereel.png')
    showsdisplayed = 0
    for data in fields:
        timestamp =  time.mktime(time.strptime(data['date'], "%Y-%m-%d"))
        datestring = (datetime.datetime.fromtimestamp(timestamp)).strftime('%A, %b %d')
        days = (timestamp - todaytimestamp) / 86400
        relative = getRelativeDate(days)
        main.addLink('[COLOR yellow]'+str(datestring)+'[/COLOR]  [COLOR orange]('+relative+')[/COLOR]','',art+'/link.png')
        for showdata in data['episodes']:
            if showdata['episode']['season'] < 10: sea='0'+str(showdata['episode']['season'])
            else: sea=str(showdata['episode']['season'])
            if showdata['episode']['number'] < 10: epi='0'+str(showdata['episode']['number'])
            else: epi=str(showdata['episode']['number'])
            episodenumber= 'S'+sea+'E'+epi
            airtime = showdata['show']['air_time_localized'].upper().replace("AM"," AM").replace("PM"," PM")+' on ' + showdata['show']['network']
            main.addDir(showdata['show']['title'].encode('utf-8')+' '+episodenumber+' [COLOR red]"'+showdata['episode']['title'].encode('utf-8')+
                        '"[/COLOR] [COLOR blue]'+ airtime.encode('utf-8') +'[/COLOR]','TV',20,showdata['show']['images']['poster'].encode('utf-8'))
            #            showdata['episode']['overview'].encode('utf-8'),showdata['episode']['images']['screen'].encode('utf-8'))
            showsdisplayed += 1
    if not showsdisplayed: main.removeFile(cached_path)
Example #4
0
def MAINSIDE(cacheOnly=False):
    import time
    import datetime
    cached_path = os.path.join(os.path.join(main.datapath, 'Cache'),
                               'Sidereel')
    cached = main.getFile(cached_path)
    if (not cached or (cached and time.mktime(
            datetime.date.today().timetuple()) > os.stat(cached_path).st_mtime)
            or xbmcgui.Window(10000).getProperty('Refresh_Sidreel')):
        from t0mm0.common.net import Net as net
        setCookie(MAINURL)
        response = net().http_GET(MAINURL)
        link = response.content
        link = cleanHex(link)
        link = link.replace('\r',
                            '').replace('\n', '').replace('\t', '').replace(
                                '&nbsp;', '').replace('  ', '')
        today = re.compile(
            "<li class='current'>[^/]+?<h2 class='[^']*?'><span>(.+?)</span></h2><div(.+?)/div></div></li>",
            re.DOTALL).findall(link)
        match = re.compile(
            "<li class=''>[^/]+?<h2 class='[^']+?'><span>(.+?)</span></h2><div(.+?)/div></div></li>",
            re.DOTALL).findall(link)
        match = today + match
        if match:
            main.setFile(cached_path, str(match), True)
        else:
            main.addLink(
                '[COLOR red]Something is wrong, Check if you credentials are correct[/COLOR]',
                'TV', '')
            main.addSpecial(
                '[COLOR yellow]User: [/COLOR][COLOR white]' + user +
                '[/COLOR] --- Click to EDIT', 'USER', 456, '')
            main.addSpecial(
                '[COLOR yellow]Pass: [/COLOR][COLOR white]' + passw +
                '[/COLOR] --- Click to EDIT', 'PASS', 456, '')
            main.addLink(
                '[COLOR orange]If they are correct Clear Cache & Cookies Below[/COLOR]',
                'TV', '')
            main.addDir('[COLOR blue]Clear Cache & Cookies[/COLOR]',
                        'MashCache', 416, art + '/maintenance.png')
            main.addLink(
                '[COLOR red]If that does not solve the issue post log on forums[/COLOR]',
                'TV', '')
        xbmcgui.Window(10000).clearProperty('Refresh_Sidreel')
    else:
        match = eval(cached)
    if cacheOnly: return False
    main.GA("None", "SideReel")
    main.addDir('Search for Shows', 'TV', 398, art + '/search.png')
    main.addDir('All Tracked Shows', 'TV', 402, art + '/sidereel.png')

    import calendar
    todaytimestamp = calendar.timegm(
        time.strptime(
            time.strftime("%b") + " " + time.strftime("%d"), "%b %d"))
    showsdisplayed = 0
    for date, shows in match:
        print shows
        if 'data-track-label="TrackerPage"' in shows:
            s = re.sub('(?i)^.*?,(.*)$', '\\1', date).strip()
            timestamp = calendar.timegm(time.strptime(s, "%b %d"))
            days = (timestamp - todaytimestamp) / 86400
            relative = getRelativeDate(days)
            main.addLink(
                '[COLOR yellow]' + date + '[/COLOR]  [COLOR orange](' +
                relative + ')[/COLOR]', '', art + '/link.png')

            match2 = re.compile(
                """data-track-label="TrackerPage" href=".+?">([^<]+?)</a><div><a class=".+?data-track-label="TrackerPage" href="([^"]+?)">([^<]+?)</a></div>""",
                re.DOTALL).findall(shows)
            for showname, seaepi, epiname in match2:
                se = re.search('season-(\d+)/episode-(\d+)', seaepi)
                if se:
                    if len(se.group(1)) == 1:
                        sea = '0' + str(se.group(1))
                    else:
                        sea = str(se.group(1))
                    if len(se.group(2)) == 1:
                        epi = '0' + str(se.group(2))
                    else:
                        epi = str(se.group(2))
                    final = 'S' + sea + 'E' + epi
                else:
                    final = ''

                main.addDir(
                    showname + ' ' + final + ' [COLOR red] "' + epiname +
                    '"[/COLOR]', 'TV', 20, art + '/sidereel.png')
                showsdisplayed += 1
    if not showsdisplayed: main.removeFile(cached_path)
Example #5
0
def showList(cacheOnly=False):
    if not user:
        xbmc.executebuiltin("XBMC.Notification(Sorry,Set Trakt user in settings,3000)")
        xbmcplugin.endOfDirectory(int(sys.argv[1]), False, False, False)
        return False
    import time, datetime, calendar

    todaytimestamp = calendar.timegm(
        time.strptime(time.strftime("%Y") + "-" + time.strftime("%m") + "-" + time.strftime("%d"), "%Y-%m-%d")
    )
    cached_path = os.path.join(os.path.join(main.datapath, "Cache"), "Trakt")
    cached = main.getFile(cached_path)
    if (
        not cached
        or (cached and time.mktime(datetime.date.today().timetuple()) > os.stat(cached_path).st_mtime)
        or xbmcgui.Window(10000).getProperty("Refresh_Trakt")
    ):
        setCookie()
        import hashlib, json

        data = {"username": user, "password": hashlib.sha1(passw).hexdigest()}
        link = main.OPENURL(
            "http://api.trakt.tv/user/calendar/shows.json/" + TRAKT_API + "/" + user + "/6daysago/14", data=data
        )
        fields = json.loads(link)
        tofront = []
        daysinfuture = 2
        daysinpast = 1
        for item in fields:
            timestamp = calendar.timegm(time.strptime(item["date"], "%Y-%m-%d"))
            if timestamp <= todaytimestamp + daysinfuture * 86400 and timestamp >= todaytimestamp - daysinpast * 86400:
                tofront.append(item)
        for item in tofront:
            fields.remove(item)
        fields = tofront + fields
        if fields:
            main.setFile(cached_path, str(fields), True)
        xbmcgui.Window(10000).clearProperty("Refresh_Trakt")
    else:
        fields = eval(cached)
    if cacheOnly:
        return False
    main.GA("None", "Trakt")
    main.addDir("Search for Shows", "TV", 430, art + "/search.png")
    main.addDir("All Tracked Shows", "TV", 431, art + "/sidereel.png")
    showsdisplayed = 0
    for data in fields:
        timestamp = calendar.timegm(time.strptime(data["date"], "%Y-%m-%d"))
        datestring = (datetime.datetime.fromtimestamp(timestamp) + datetime.timedelta(1)).strftime("%A, %b %d")
        days = (timestamp - todaytimestamp) / 86400
        relative = getRelativeDate(days)
        main.addLink(
            "[COLOR yellow]" + str(datestring) + "[/COLOR]  [COLOR orange](" + relative + ")[/COLOR]",
            "",
            art + "/link.png",
        )
        for showdata in data["episodes"]:
            if showdata["episode"]["season"] < 10:
                sea = "0" + str(showdata["episode"]["season"])
            else:
                sea = str(showdata["episode"]["season"])
            if showdata["episode"]["number"] < 10:
                epi = "0" + str(showdata["episode"]["number"])
            else:
                epi = str(showdata["episode"]["number"])
            episodenumber = "S" + sea + "E" + epi
            airtime = (
                showdata["show"]["air_time_localized"].upper().replace("AM", " AM").replace("PM", " PM")
                + " on "
                + showdata["show"]["network"]
            )
            main.addDir(
                showdata["show"]["title"].encode("utf-8")
                + " "
                + episodenumber
                + ' [COLOR red]"'
                + showdata["episode"]["title"].encode("utf-8")
                + '"[/COLOR] [COLOR blue]'
                + airtime.encode("utf-8")
                + "[/COLOR]",
                "TV",
                20,
                showdata["show"]["images"]["poster"].encode("utf-8"),
            )
            #            showdata['episode']['overview'].encode('utf-8'),showdata['episode']['images']['screen'].encode('utf-8'))
            showsdisplayed += 1
    if not showsdisplayed:
        main.removeFile(cached_path)