Пример #1
0
def ListDirectDownloadTVItems(startpage):
    subpages = 3
    main.addDir('Search Rlsmix','rlsmix',136,art+'/search.png')
    mytag = '#my'
    if re.search(mytag +'$',startpage):
        startpage = startpage.replace(mytag,'')
        myshows = '/myshows/true'
    else: 
        mytag = ''
        myshows = ''
    if 'TV' in startpage:
        startpage = 0
    try: page = int(startpage)
    except: page = 0
    urls = []
    for n in range(subpages):
        urls.append('http://directdownload.tv/index/search/keyword//qualities/'+filters+'/from/'+str(page)+myshows+'/search')
        page += 20
    cached_path = os.path.join(os.path.join(main.datapath,'Temp'), filename + '_' + str(startpage)+mytag+'.cache')
    cached = main.getFile(cached_path)
    count = 0
    if cached:
        count = ShowDirectDownloadTVItems('',cached)
    else: 
        setCookie()
        html = getBatchUrl(urls)
        count = ShowDirectDownloadTVItems(html,cached_path=cached_path)
        if not count and myshows:
            xbmcplugin.endOfDirectory(int(sys.argv[1]),False,False)
            xbmc.executebuiltin("XBMC.Notification(You are not following any shows!,Add shows on directdownload.tv,5000,"+smalllogo+")")
    strpage = str((int(startpage))/(20*subpages)+1)
    if count == subpages * 20:
        main.addDir('Page ' + strpage + ' [COLOR blue]Next Page >>>[/COLOR]',str(page)+mytag,61,art+'/next2.png')
    main.GA("TV","DirectDownloadTV")
Пример #2
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)
Пример #3
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)
Пример #4
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 = 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)
Пример #5
0
def MAIN():
    lock_file_path = os.path.join(os.path.join(main.datapath,'Temp'), 'mbox.lock')
    lock_file = main.getFile(lock_file_path)
    if not lock_file:
        try: 
            lib=os.path.join(datapath, 'MBox.zip')
            if main.downloadFile(dataurl,lib,False): xbmc.executebuiltin("XBMC.Extract(%s,%s)"%(lib,profile))
        except: pass
        main.setFile(lock_file_path,'lock')
    main.addDir('First 25 Movies','25movies',278,art+'/mbox.png')
    main.addDir('Movies','movies',278,art+'/mbox.png')
    main.addDir('TV','tv',278,art+'/mbox.png')
    main.addDir('Music','music',278,art+'/mbox.png')
Пример #6
0
def TRACKEDSHOWS():
    main.GA("SideReel", "Tracked Shows")
    from t0mm0.common.net import Net as net
    setCookie(MAINURL)
    cookie = main.getFile(cookie_file)
    user = re.findall('SrLoggedIn=(.+?);', cookie)
    if user:
        user = user[0]
        method = re.findall('SrLoginMethod=(.+?);', cookie)[0]
        token = re.findall('remember_user_token="(.+?)";', cookie)[0]
        session = re.findall('sidereel_session=(.+?);', cookie)[0]
        header = {
            'Accept':
            'application/json, text/javascript, */*; q=0.01',
            'Accept-Encoding':
            'gzip,deflate,sdch',
            'Accept-Language':
            'en-US,en;q=0.8',
            'Cache-Control':
            'max-age=0',
            'Connection':
            'keep-alive',
            'Content-Type':
            'application/x-www-form-urlencoded; charset=UTF-8',
            'Cookie':
            'SrLoggedIn=' + user + '; SrLoginMethod=' + method +
            '; remember_user_token=' + token + '; _sidereel_session=' +
            session + ';',
            'Referer':
            MAINURL,
            'X-Requested-With':
            'XMLHttpRequest'
        }
        #post_data={'authenticity_token':auth,'tv_show_id':showID}
        data = net().http_GET('http://www.sidereel.com/users/tracked_tv_shows',
                              header).content
        data = data.encode("utf8", "ignore")
        match = re.compile(
            '"tv_show":{"id":(.+?),"name":"(.+?)",.+?,"status":(.+?),"summary":(.+?),"network":(.+?),.+?,"cached_genre_list":(.+?),.+?,"canonical_url":"(.+?)",.+?,"image_url_medium":"(.+?)",',
            re.DOTALL).findall(data)
        for id, name, status, plot, network, genre, url, thumb in match:
            main.addPlayc(
                name + ' [COLOR blue]' +
                network.replace('"', '').replace('null', '') +
                '[/COLOR] [COLOR red]' +
                status.replace('"', '').replace('null', '') + '[/COLOR]',
                '<id>' + id + '<xo>' + url + '</xo>', 400, thumb,
                plot.replace('"', '').replace('null', ''), '', '',
                genre.replace('"', '').replace('null', ''), '')
Пример #7
0
def ListSceneLogItems(murl, quality='all'):
    if murl.startswith('Movies'):
        main.addDir('Search SceneLog', 'Movies', 659, art + '/search.png')
        subpages = 5
        category = "movies"
    elif murl.startswith('TV'):
        main.addDir('Search SceneLog', 'TV', 659, art + '/search.png')
        subpages = 5
        category = "tv-shows"
    parts = murl.split('-', 1)
    max = subpages
    try:
        pages = parts[1].split(',', 1)
        page = int(pages[0])
        max = int(pages[1])
        murl = parts[0]
    except:
        page = 0
    page = page * subpages
    html = ''
    urls = []
    for n in range(subpages):
        if page + n + 1 > max: break
        urls.append('http://scnlog.eu/' + category + '/page/' +
                    str(page + n + 1) + '/')
    cached_path = os.path.join(
        os.path.join(main.datapath, 'Temp'),
        filename + '_' + murl + "-" + str(page) + '.cache')
    cached = main.getFile(cached_path)
    if cached:
        xbmc.executebuiltin("XBMC.Dialog.Close(busydialog,true)")
        html = cached
    else:
        html = main.batchOPENURL(urls)
        main.setFile(cached_path, html)
    hasNextPage = re.compile('<strong>&raquo;</strong>').findall(html)
    if len(hasNextPage) < subpages:
        page = None
    hasMax = re.compile('page/(\d+)/">Last &raquo;').findall(html)
    if hasMax:
        max = hasMax[0]
    if html:
        ShowSceneLogItems(html, murl, quality)
        if not page is None:
            main.addDir('Page ' + str(page / subpages + 1) + ', Next Page >>>',
                        murl + "-" + str(page / subpages + 1) + "," + max, 657,
                        art + '/next2.png')
    main.GA("Movies-TV", "SceneLog")
    main.VIEWS()
Пример #8
0
def MAIN():
    lock_file_path = os.path.join(os.path.join(main.datapath, "Temp"), "mbox.lock")
    lock_file = main.getFile(lock_file_path)
    if not lock_file:
        try:
            lib = os.path.join(datapath, "MBox.zip")
            if main.downloadFile(dataurl, lib, False):
                xbmc.executebuiltin("XBMC.Extract(%s,%s)" % (lib, profile))
        except:
            pass
        main.setFile(lock_file_path, "lock")
    main.addDir("First 25 Movies", "25movies", 278, art + "/mbox.png")
    main.addDir("Movies", "movies", 278, art + "/mbox.png")
    main.addDir("TV", "tv", 278, art + "/mbox.png")
    main.addDir("Music", "music", 278, art + "/mbox.png")
    main.GA("Plugin", "MBox")
Пример #9
0
def MAIN():
    lock_file_path = os.path.join(os.path.join(main.datapath, 'Temp'),
                                  'mbox.lock')
    lock_file = main.getFile(lock_file_path)
    if not lock_file:
        try:
            lib = os.path.join(datapath, 'MBox.zip')
            if main.downloadFile(dataurl, lib, False):
                xbmc.executebuiltin("XBMC.Extract(%s,%s)" % (lib, profile))
        except:
            pass
        main.setFile(lock_file_path, 'lock')
    main.addDir('First 25 Movies', '25movies', 278, art + '/mbox.png')
    main.addDir('Movies', 'movies', 278, art + '/mbox.png')
    main.addDir('TV', 'tv', 278, art + '/mbox.png')
    main.addDir('Music', 'music', 278, art + '/mbox.png')
    main.GA("Plugin", "MBox")
Пример #10
0
def ListSceneLogItems(murl,quality='all'):
    if murl.startswith('Movies'):
        main.addDir('Search SceneLog','Movies',659,art+'/search.png')
        subpages = 5
        category = "movies"
    elif murl.startswith('TV'):
        main.addDir('Search SceneLog','TV',659,art+'/search.png')
        subpages = 5
        category = "tv-shows"
    parts = murl.split('-', 1 );
    max = subpages
    try:
        pages = parts[1].split(',', 1 );
        page = int(pages[0])
        max = int(pages[1])
        murl = parts[0]
    except:
        page = 0
    page = page * subpages;
    html = ''
    urls = []
    for n in range(subpages):
        if page + n + 1 > max: break
        urls.append('http://scnlog.eu/'+category+'/page/'+str(page+n+1)+'/')
    cached_path = os.path.join(os.path.join(main.datapath,'Temp'), filename + '_' + murl+"-"+str(page)+'.cache')
    cached = main.getFile(cached_path)
    if cached:
        xbmc.executebuiltin("XBMC.Dialog.Close(busydialog,true)")          
        html = cached
    else:
        html = main.batchOPENURL(urls)
        main.setFile(cached_path,html)
    hasNextPage = re.compile('<strong>&raquo;</strong>').findall(html)
    if len(hasNextPage) < subpages:
        page = None
    hasMax = re.compile('page/(\d+)/">Last &raquo;').findall(html)
    if hasMax:
        max = hasMax[0]
    if html:
        ShowSceneLogItems(html,murl,quality)
        if not page is None:
            main.addDir('Page ' + str(page/subpages+1) + ', Next Page >>>',murl + "-" + str(page/subpages+1) + "," + max,657,art+'/next2.png')
    main.GA("Movies-TV","SceneLog")
    main.VIEWS()
Пример #11
0
def ListDirectDownloadTVItems(startpage):
    subpages = 3
    main.addDir('Search Rlsmix', 'rlsmix', 136, art + '/search.png')
    mytag = '#my'
    if re.search(mytag + '$', startpage):
        startpage = startpage.replace(mytag, '')
        myshows = '/myshows/true'
    else:
        mytag = ''
        myshows = ''
    if 'TV' in startpage:
        startpage = 0
    try:
        page = int(startpage)
    except:
        page = 0
    urls = []
    for n in range(subpages):
        urls.append(
            'http://directdownload.tv/index/search/keyword//qualities/' +
            filters + '/from/' + str(page) + myshows + '/search')
        page += 20
    cached_path = os.path.join(
        os.path.join(main.datapath, 'Temp'),
        filename + '_' + str(startpage) + mytag + '.cache')
    cached = main.getFile(cached_path)
    count = 0
    if cached:
        count = ShowDirectDownloadTVItems('', cached)
    else:
        setCookie()
        html = getBatchUrl(urls)
        count = ShowDirectDownloadTVItems(html, cached_path=cached_path)
        if not count and myshows:
            xbmcplugin.endOfDirectory(int(sys.argv[1]), False, False)
            xbmc.executebuiltin(
                "XBMC.Notification(You are not following any shows!,Add shows on directdownload.tv,5000,"
                + smalllogo + ")")
    strpage = str((int(startpage)) / (20 * subpages) + 1)
    if count == subpages * 20:
        main.addDir('Page ' + strpage + ' [COLOR blue]Next Page >>>[/COLOR]',
                    str(page) + mytag, 61, art + '/next2.png')
    main.GA("TV", "DirectDownloadTV")
Пример #12
0
def TRACKEDSHOWS():
    main.GA("SideReel","Tracked Shows")
    from t0mm0.common.net import Net as net
    setCookie(MAINURL)
    cookie = main.getFile(cookie_file)
    user = re.findall('SrLoggedIn=(.+?);',cookie)
    if user:
        user = user[0]
        method=re.findall('SrLoginMethod=(.+?);',cookie)[0]
        token=re.findall('remember_user_token="(.+?)";',cookie)[0]
        session=re.findall('sidereel_session=(.+?);',cookie)[0]
        header={'Accept':'application/json, text/javascript, */*; q=0.01','Accept-Encoding':'gzip,deflate,sdch','Accept-Language':'en-US,en;q=0.8','Cache-Control':'max-age=0',
                'Connection':'keep-alive','Content-Type':'application/x-www-form-urlencoded; charset=UTF-8',
                'Cookie':'SrLoggedIn='+user+'; SrLoginMethod='+method+'; remember_user_token='+token+'; _sidereel_session='+session+';',
                'Referer':MAINURL,'X-Requested-With':'XMLHttpRequest'}
        #post_data={'authenticity_token':auth,'tv_show_id':showID}
        data=net().http_GET('http://www.sidereel.com/users/tracked_tv_shows',header).content
        match=re.compile('"tv_show":{"id":(.+?),"name":"(.+?)",.+?,"status":(.+?),"summary":(.+?),"network":(.+?),.+?,"cached_genre_list":(.+?),.+?,"canonical_url":"(.+?)",.+?,"image_url_medium":"(.+?)",',re.DOTALL).findall(data)
        for id,name,status,plot,network,genre,url,thumb in match:
            main.addPlayc(name+' [COLOR blue]'+network.replace('"','').replace('null','')+'[/COLOR] [COLOR red]'+status.replace('"','').replace('null','')+'[/COLOR]' ,'<id>'+id+'<xo>'+url+'</xo>',400,thumb,plot.replace('"','').replace('null',''),'','',genre.replace('"','').replace('null',''),'')
Пример #13
0
prettyName='Trakt'
TRAKT_API = '4ff3c522308d31f438ec7213bfd3aa1d'

def downloadFile(url,dest):
    try:
        urllib.urlretrieve(url,dest)
    except Exception, e:
        dialog = xbmcgui.Dialog()
        main.ErrorReport(e)
        dialog.ok("Mash Up", "Report the error below at " + main.supportsite, str(e), "We will try our best to help you")

user = selfAddon.getSetting('trusername')
passw = selfAddon.getSetting('trpassword')
cookie_file = os.path.join(os.path.join(main.datapath,'Cookies'), 'trakt.cookies')
api_file = os.path.join(os.path.join(main.datapath,'Cookies'), 'trakt.api')
apifile = main.getFile(api_file)
if apifile: TRAKT_API = apifile

if user == '' or passw == '':
    if os.path.exists(cookie_file):
        try: os.remove(cookie_file)
        except: pass
    dialog = xbmcgui.Dialog()
    ret = dialog.yesno('[COLOR=FF67cc33]MashUp[/COLOR]', 'Please set your Trakt.tv credentials','or register if you don have an account','','Cancel','Login')
    if ret == 1:
        keyb = xbmc.Keyboard('', 'Enter Trakt Username')
        keyb.doModal()
        if (keyb.isConfirmed()):
            username = keyb.getText()
            keyb = xbmc.Keyboard('', 'Enter Trakt Password:')
            keyb.doModal()
Пример #14
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)
Пример #15
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)
Пример #16
0
prettyName='Trakt'
TRAKT_API = '4ff3c522308d31f438ec7213bfd3aa1d'

def downloadFile(url,dest):
    try:
        urllib.urlretrieve(url,dest)
    except Exception, e:
        dialog = xbmcgui.Dialog()
        main.ErrorReport(e)
        dialog.ok("Mash Up", "Report the error below at " + main.supportsite, str(e), "We will try our best to help you")

user = selfAddon.getSetting('trusername')
passw = selfAddon.getSetting('trpassword')
cookie_file = os.path.join(os.path.join(main.datapath,'Cookies'), 'trakt.cookies')
api_file = os.path.join(os.path.join(main.datapath,'Cookies'), 'trakt.api')
apifile = main.getFile(api_file)
if apifile: TRAKT_API = apifile

if user == '' or passw == '':
    if os.path.exists(cookie_file):
        try: os.remove(cookie_file)
        except: pass
    dialog = xbmcgui.Dialog()
    ret = dialog.yesno('[COLOR=FF67cc33]MashUp[/COLOR]', 'Please set your Trakt.tv credentials','or register if you don have an account','','Cancel','Login')
    if ret == 1:
        keyb = xbmc.Keyboard('', 'Enter Trakt Username')
        keyb.doModal()
        if (keyb.isConfirmed()):
            username = keyb.getText()
            keyb = xbmc.Keyboard('', 'Enter Trakt Password:')
            keyb.doModal()