def ADD_MOVIE_ITEM(moviedata, cmmode=0):
    asin, hd_asin, movietitle, trailer, poster, plot, director, writer, runtime, year, premiered, studio, mpaa, actors, genres, stars, votes, fanart, isprime, isHD, isAdult, popularity, recent, audio = moviedata
    infoLabels = {'Title': movietitle,
                  'Plot': plot,
                  'mediatype': "movie",
                  'Cast': actors.split(',') if actors else [],
                  'Director': director,
                  'Year': year,
                  'Premiered': premiered,
                  'Rating': stars,
                  'Votes': votes,
                  'Genre': genres,
                  'mpaa': mpaa,
                  'Studio': studio,
                  'Duration': int(runtime) * 60,
                  'AudioChannels': audio,
                  'Thumb': poster,
                  'Fanart': fanart,
                  'isHD': isHD,
                  'isAdult': isAdult}
    asin = asin.split(',')[0]
    cm = []
    cm.append((common.getString(30180 + cmmode) % common.getString(30154), 'XBMC.RunPlugin(%s?mode=<common>&sitemode=<toggleWatchlist>&asin=<%s>&remove=<%s>)' % (sys.argv[0], asin, cmmode)))
    cm.append((common.getString(30183), 'Container.Update(%s?mode=<appfeed>&sitemode=<getSimilarities>&asin=<%s>)' % (sys.argv[0], asin)))
    common.addVideo(movietitle, asin, poster, fanart, infoLabels=infoLabels, cm=cm, trailer=trailer, isAdult=isAdult, isHD=isHD)
Example #2
0
def ListMenu():
    list_ = common.args.url
    common.addDir(common.getString(30104), 'appfeed', 'ListCont',
                  common.movielib % list_)
    common.addDir(common.getString(30107), 'appfeed', 'ListCont',
                  common.tvlib % list_)
    common.xbmcplugin.endOfDirectory(common.pluginhandle)
Example #3
0
def updateAll():
    if common.updateRunning():
        return

    cj = common.mechanizeLogin()
    if not cj:
        return

    import movies
    import tv
    from datetime import datetime

    common.addon.setSetting('update_running', datetime.today().strftime('%Y-%m-%d %H:%M'))
    common.Log('Starting DBUpdate')
    Notif = xbmcgui.Dialog().notification
    Notif(common.__plugin__, common.getString(30106), sound=False)
    tv.addTVdb(False, cj=cj)
    movies.addMoviesdb(False, cj=cj)
    NewAsins = common.getCategories()
    movies.setNewest(NewAsins)
    tv.setNewest(NewAsins)
    movies.updateFanart()
    tv.updateFanart()
    common.addon.setSetting('last_update', datetime.today().strftime('%Y-%m-%d'))
    common.addon.setSetting('update_running', 'false')
    Notif(common.__plugin__, common.getString(30126), sound=False)
    common.Log('DBUpdate finished')
Example #4
0
def ADD_SHOW_ITEM(showdata, mode='listtv', submode='LIST_TV_SEASONS', cmmode=0):
    asin, seriestitle, plot, network, mpaa, genres, actors, premiered, year, stars, votes, seasontotal, episodetotal, audio, isHD, isprime, empty, empty, empty, poster, banner, fanart = showdata
    infoLabels = {'Title': seriestitle,
                  'Plot': plot,
                  'mediatype': "tvshow",
                  'MPAA': mpaa,
                  'Cast': actors.split(',') if actors else None,
                  'Year': year,
                  'Premiered': premiered,
                  'Rating': stars,
                  'Votes': votes,
                  'Genre': genres,
                  'Episode': episodetotal,
                  'TotalSeasons': seasontotal,
                  'Studio': network,
                  'AudioChannels': audio
                  }
    infoLabels = {k: v for k, v in infoLabels.items() if v}
    submode = 'LIST_TV_SEASONS' if mode == 'listtv' else submode
    poster = '' if not poster else poster
    infoLabels['Thumb'] = poster
    infoLabels['Fanart'] = fanart
    infoLabels['Asins'] = asin
    asin = asin.split(',')[0]
    cm = []
    cm.append((common.getString(30180 + cmmode) % common.getString(30166), 'XBMC.RunPlugin(%s?mode=<common>&sitemode=<toggleWatchlist>&asin=<%s>&remove=<%s>)' % (sys.argv[0], asin, cmmode)))
    cm.append((common.getString(30183), 'Container.Update(%s?mode=<appfeed>&sitemode=<getSimilarities>&asin=<%s>)' % (sys.argv[0], asin)))
    cm.append((common.getString(30155) % common.getString(30166), 'XBMC.RunPlugin(%s?mode=<tv>&sitemode=<delfromTVdb>&asins=<%s>&table=<shows>&title=<%s>)' % (sys.argv[0], urllib.quote_plus(infoLabels['Asins']), urllib.quote_plus(seriestitle))))
    common.addDir(seriestitle, mode, submode, infoLabels['Asins'], poster, fanart, infoLabels, cm=cm)
Example #5
0
File: play.py Project: WhileE/xbmc
def getFlashVars():
    cookie = common.mechanizeLogin()
    if not cookie:
        return False
    url = common.BASE_URL + '/gp/deal/ajax/getNotifierResources.html'
    showpage = json.loads(common.getURL(url, useCookie=cookie))

    if not showpage:
        Dialog.notification(common.__plugin__, Error({'errorCode': 'invalidrequest', 'message': 'getFlashVars'}),
                            xbmcgui.NOTIFICATION_ERROR)
        return False

    values = {'asin': common.args.asin,
              'deviceTypeID': 'AOAGZA014O5RE',
              'userAgent': common.UserAgent}
    values.update(showpage['resourceData']['GBCustomerData'])

    if 'customerId' not in values:
        Dialog.notification(common.getString(30200), common.getString(30210), xbmcgui.NOTIFICATION_ERROR)
        return False

    values['deviceID'] = common.gen_id()
    rand = 'onWebToken_' + str(random.randint(0, 484))
    pltoken = common.getURL(common.BASE_URL + "/gp/video/streaming/player-token.json?callback=" + rand,
                            useCookie=cookie)
    try:
        values['token'] = re.compile('"([^"]*).*"([^"]*)"').findall(pltoken)[0][1]
    except:
        Dialog.notification(common.getString(30200), common.getString(30201), xbmcgui.NOTIFICATION_ERROR)
        return False
    return values
Example #6
0
def ASIN_ADD(title):
    isAdult = False
    stars = None
    votes = None
    poster = None
    runtime = None
    premiered = None
    year = None
    mpaa = ''
    genres = ''
    asin, isHD, isPrime, audio = common.GET_ASINS(title)
    movietitle = title['title']
    plot = title.get('synopsis')
    fanart = title.get('heroUrl')
    director = title.get('director')
    if 'runtime' in title:
        runtime = str(title['runtime']['valueMillis'] / 60000)
    if 'releaseOrFirstAiringDate' in title:
        premiered = title['releaseOrFirstAiringDate']['valueFormatted'].split('T')[0]
        year = int(premiered.split('-')[0])
    studio = title.get('studioOrNetwork')
    if 'regulatoryRating' in title:
        if title['regulatoryRating'] == 'not_checked':
            mpaa = common.getString(30171)
        else:
            mpaa = common.getString(30170) + title['regulatoryRating']
    actors = title.get('starringCast')
    if 'genres' in title:
        genres = ' / '.join(title['genres']).replace('_', ' & ').replace('Musikfilm & Tanz', 'Musikfilm, Tanz')
    trailer = title.get('trailerAvailable')
    if 'customerReviewCollection' in title:
        stars = float(title['customerReviewCollection']['customerReviewSummary']['averageOverallRating']) * 2
        votes = str(title['customerReviewCollection']['customerReviewSummary']['totalReviewCount'])
    elif 'amazonRating' in title:
        if 'rating' in title['amazonRating']:
            stars = float(title['amazonRating']['rating']) * 2
        if 'count' in title['amazonRating']:
            votes = str(title['amazonRating']['count'])
    if 'restrictions' in title:
        for rest in title['restrictions']:
            if rest['action'] == 'playback' and rest['type'] == 'ageVerificationRequired':
                isAdult = True
                break
    if 'images' in title['formats'][0]:
        thumbnailUrl = title['formats'][0]['images'][0]['uri']
        thumbnailFilename = thumbnailUrl.split('/')[-1]
        thumbnailBase = thumbnailUrl.replace(thumbnailFilename, '')
        poster = thumbnailBase + thumbnailFilename.split('.')[0] + '.jpg'
    titelnum = 0
    if 'bbl test' not in movietitle.lower() and 'test movie' not in movietitle.lower():
        moviedata = [common.cleanData(x) for x in [asin, None, common.checkCase(movietitle), trailer, poster, plot, director, None, runtime, year, premiered, studio, mpaa, actors, genres, stars, votes, fanart, isPrime, isHD, isAdult, None, None, audio]]
        c = MovieDB.cursor()
        num = c.execute('insert or ignore into movies values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', moviedata).rowcount
        if num:
            MovieDB.commit()
        titelnum += num
    return titelnum
Example #7
0
def copyDB(source, dest, ask=False):
    import shutil
    if ask:
        if not Dialog.yesno(getString(30193), getString(30194)):
            shutil.copystat(source['tv'], dest['tv'])
            shutil.copystat(source['movie'], dest['movie'])
            return
    shutil.copy2(source['tv'], dest['tv'])
    shutil.copy2(source['movie'], dest['movie'])
Example #8
0
def addMoviesdb(full_update=True):
    try:
        if common.args.url == 'u':
            full_update = False
    except: pass
    dialog = xbmcgui.DialogProgress()

    if full_update:
        if common.updateRunning(): return
        dialog.create(common.getString(30120))
        dialog.update(0,common.getString(30121))
        createMoviedb()
        MOVIE_ASINS = []
        full_update = True
    else:
        MOVIE_ASINS = getMoviedbAsins(list=True)

    page = 1
    goAhead = 1
    endIndex = 0
    new_mov = 0
    
    while goAhead == 1:
        page+=1
        json = appfeed.getList('Movie', endIndex, NumberOfResults=MAX)
        titles = json['message']['body']['titles']
        if titles:
            for title in titles:
                if full_update and dialog.iscanceled():
                    goAhead = -1
                    break
                if title.has_key('titleId'):
                    endIndex += 1
                    asin = title['titleId']
                    found, MOVIE_ASINS = common.compasin(MOVIE_ASINS, asin)
                    if not found:
                        new_mov += ASIN_ADD(title)
                    updateMoviedb(asin, 'popularity', endIndex)
            if len(titles) < MAX: goAhead = 0
            else: endIndex = endIndex - int(MAX/4)
        else:
            goAhead = 0
        if full_update: dialog.update(int((endIndex)*100.0/MOV_TOTAL), common.getString(30122) % page, common.getString(30123) % new_mov)
        if full_update and dialog.iscanceled(): goAhead = -1
    if goAhead == 0:
        updateLibrary()
        common.addon.setSetting("MoviesTotal",str(endIndex))
        common.Log('Movie Update: New %s Deleted %s Total %s' % (new_mov, deleteremoved(MOVIE_ASINS), endIndex))
        if full_update: 
            setNewest()
            dialog.close()
            updateFanart()
        xbmc.executebuiltin("XBMC.Container.Refresh")
        MovieDB.commit()
Example #9
0
def ADD_SEASON_ITEM(seasondata, mode='listtv', submode='LIST_EPISODES_DB', disptitle=False, cmmode=0, onlyinfo=False, export=False):
    asin,seriesASIN,season,seriestitle,plot,actors,network,mpaa,genres,premiered,year,stars,votes,episodetotal,audio,empty,empty,isHD,isprime,empty,poster,banner,fanart = seasondata
    infoLabels={'Title': seriestitle,'TVShowTitle':seriestitle}
    if plot:
        infoLabels['Plot'] = plot
    if mpaa:
        infoLabels['MPAA'] = mpaa
    if actors:
        infoLabels['Cast'] = actors.split(',')
    if year:
        infoLabels['Year'] = year
    if premiered:
        infoLabels['Premiered'] = premiered
    if stars:
        infoLabels['Rating'] = stars           
    if votes:
        infoLabels['Votes'] = votes  
    if genres:
        infoLabels['Genre'] = genres 
    if episodetotal:
        infoLabels['Episode'] = episodetotal
    if season:
        infoLabels['Season'] = season
    if network:
        infoLabels['Studio'] = network
    if audio:
        infoLabels['AudioChannels'] = audio
    displayname = ''
    if disptitle: displayname = seriestitle + ' - '
    if season != 0 and len(str(season)) < 3: displayname += common.getString(30167, True) + ' ' + str(season)
    elif len(str(season)) > 2: displayname += common.getString(30168, True) + str(season)
    else: displayname += common.getString(30169, True)
    if not fanart or common.na:
        fanart = poster
    if showfanart == 'true': 
        fanart, cover = getFanart(seriesASIN)
    infoLabels['TotalSeasons'] = 1
    infoLabels['Thumb'] = poster
    infoLabels['Fanart'] = fanart
    infoLabels['Asins'] = asin
    asin = asin.split(',')[0]
    if export:
        xbmclibrary.EXPORT_SEASON(asin)
        return
    cm = []
    cm.append((common.getString(30180+cmmode) % common.getString(30167), 'XBMC.RunPlugin(%s?mode=<common>&sitemode=<%s>&asin=<%s>)' % (sys.argv[0], watch_mode[cmmode], asin)))
    cm.append((common.getString(30185) % common.getString(30167), 'XBMC.RunPlugin(%s?mode=<xbmclibrary>&sitemode=<EXPORT_SEASON>&asin=<%s>)' % (sys.argv[0], asin)))
    cm.append((common.getString(30186), 'XBMC.RunPlugin(%s?mode=<xbmclibrary>&sitemode=<UpdateLibrary>)' % sys.argv[0]))
    cm.append((common.getString(30155) % common.getString(30167), 'XBMC.RunPlugin(%s?mode=<tv>&sitemode=<delfromTVdb>&asins=<%s>&table=<seasons>&title=<%s>)' % ( sys.argv[0], urllib.quote_plus(infoLabels['Asins']), urllib.quote_plus(displayname))))
    if onlyinfo:
        return infoLabels
    else:
        common.addDir(displayname,mode,submode,infoLabels['Asins'],poster,fanart,infoLabels,isHD=isHD,cm=cm)
Example #10
0
def LIST_MOVIE_ROOT():
    common.addDir(common.getString(30100),'listmovie','LIST_MOVIES_SORTED','popularity')
    common.addDir(common.getString(30110),'listmovie','LIST_MOVIES_SORTED','recent')
    common.addDir(common.getString(30149),'listmovie','LIST_MOVIES_CATS')
    common.addDir(common.getString(30143),'listmovie','LIST_MOVIES')
    common.addDir(common.getString(30144),'listmovie','LIST_MOVIE_TYPES','genres')
    common.addDir(common.getString(30145),'listmovie','LIST_MOVIE_TYPES','year')
    common.addDir(common.getString(30146),'listmovie','LIST_MOVIE_TYPES','studio')
    common.addDir(common.getString(30158),'listmovie','LIST_MOVIE_TYPES','actors')
    common.addDir(common.getString(30147),'listmovie','LIST_MOVIE_TYPES','mpaa')
    common.addDir(common.getString(30148),'listmovie','LIST_MOVIE_TYPES','director')
    xbmcplugin.endOfDirectory(pluginhandle)
Example #11
0
def SetupAmazonLibrary():
    common.Log('Trying to add Amazon source paths...')
    source_path = os.path.join(common.profilpath, 'sources.xml')
    source_added = False
    
    try:
        file = open(source_path)
        soup = BeautifulSoup(file)
        file.close()
    except:
        subtags = ['programs', 'video', 'music', 'pictures', 'files']
        soup = BeautifulSoup('<sources></sources>')
        root = soup.sources
        for cat in subtags:
            cat_tag = Tag(soup, cat)
            def_tag = Tag(soup, 'default')
            def_tag['pathversion'] = 1
            cat_tag.append(def_tag)
            root.append(cat_tag)

    video = soup.find("video")      
        
    if len(soup.findAll(text="Amazon Movies")) < 1:
        movie_source_tag = Tag(soup, "source")
        movie_name_tag = Tag(soup, "name")
        movie_name_tag.insert(0, "Amazon Movies")
        movie_path_tag = Tag(soup, "path")
        movie_path_tag['pathversion'] = 1
        movie_path_tag.insert(0, MOVIE_PATH)
        movie_source_tag.insert(0, movie_name_tag)
        movie_source_tag.insert(1, movie_path_tag)
        video.insert(2, movie_source_tag)
        source_added = True

    if len(soup.findAll(text="Amazon TV")) < 1: 
        tvshow_source_tag = Tag(soup, "source")
        tvshow_name_tag = Tag(soup, "name")
        tvshow_name_tag.insert(0, "Amazon TV")
        tvshow_path_tag = Tag(soup, "path")
        tvshow_path_tag['pathversion'] = 1
        tvshow_path_tag.insert(0, TV_SHOWS_PATH)
        tvshow_source_tag.insert(0, tvshow_name_tag)
        tvshow_source_tag.insert(1, tvshow_path_tag)
        video.insert(2, tvshow_source_tag)
        source_added = True
    
    if source_added:
        common.Log('Source paths added!')
        SaveFile(source_path, str(soup))
        dialog.ok(common.getString(30187), common.getString(30188), common.getString(30189), common.getString(30190))
        if dialog.yesno(common.getString(30191), common.getString(30192)):
            xbmc.executebuiltin('RestartApp')
Example #12
0
def ADD_EPISODE_ITEM(episodedata, onlyinfo=False, export=False):
    asin,seasonASIN,seriesASIN,seriestitle,season,episode,poster,mpaa,actors,genres,episodetitle,network,stars,votes,fanart,plot,airdate,year,runtime,isHD,isprime,isAdult,audio = episodedata
    infoLabels={'Title': episodetitle,'TVShowTitle':seriestitle,
                'Episode': episode,'Season':season}
    if plot:
        infoLabels['Plot'] = plot
    if airdate:
        infoLabels['Premiered'] = airdate 
    if year:
        infoLabels['Year'] = year
    if runtime:
        infoLabels['Duration'] = runtime
    if mpaa:
        infoLabels['MPAA'] = mpaa
    if actors:
        infoLabels['Cast'] = actors.split(',')
    if stars:
        infoLabels['Rating'] = stars           
    if votes:
        infoLabels['Votes'] = votes  
    if genres:
        infoLabels['Genre'] = genres 
    if network:
        infoLabels['Studio'] = network
    if audio:
        infoLabels['AudioChannels'] = audio
    if not fanart or fanart == common.na:
        fanart = poster

    displayname = str(episode) + ' - ' + episodetitle 
    displayname = displayname.replace('"','')
    tvfanart, tvposter = getFanart(seriesASIN)
    if showfanart == 'true': 
        fanart = tvfanart
    infoLabels['Fanart'] = fanart
    infoLabels['Thumb'] = poster
    infoLabels['Poster'] = tvposter
    infoLabels['Title'] = displayname
    infoLabels['isHD'] = isHD
    infoLabels['isAdult'] = isAdult
    infoLabels['seriesASIN'] = seriesASIN
    asin = asin.split(',')[0]
    if export:
        xbmclibrary.EXPORT_EPISODE(asin)
        return
    cm = []
    cm.append((common.getString(30185) % common.getString(30173), 'XBMC.RunPlugin(%s?mode=<xbmclibrary>&sitemode=<EXPORT_EPISODE>&asin=<%s>)' % (sys.argv[0], asin)))
    cm.append((common.getString(30186), 'XBMC.RunPlugin(%s?mode=<xbmclibrary>&sitemode=<UpdateLibrary>)' % sys.argv[0]))
    if onlyinfo:
        return infoLabels
    else:
        common.addVideo(displayname,asin,poster,fanart,infoLabels=infoLabels,isAdult=isAdult,isHD=isHD,cm=cm)
Example #13
0
def connSQL(dbname):
    cnx = None
    if usesqlite:
        from sqlite3 import dbapi2
        DBfile = getDBlocation(dbname)
        if not xbmcvfs.exists(DBfile):
            cnx = dbapi2.connect(DBfile)
            cnx.text_factory = str
            createDatabase(cnx, dbname)
        else:
            cnx = dbapi2.connect(DBfile)
            cnx.text_factory = str
    else:
        import mysql.connector
        from mysql.connector import errorcode
        dbname = 'amazon_' + dbname
        mysql_config = {
            'host': addon.getSetting('dbhost'),
            'port': addon.getSetting('dbport'),
            'user': addon.getSetting('dbuser'),
            'password': addon.getSetting('dbpass'),
            'database': dbname,
            'use_unicode': False,
            'get_warnings': True,
            'buffered': True
        }
        try:
            cnx = mysql.connector.connect(**mysql_config)
        except mysql.connector.Error as err:
            if err.errno == errorcode.CR_CONN_HOST_ERROR:
                Dialog.notification('MySQL/MariaDB', getString(30224),
                                    xbmcgui.NOTIFICATION_ERROR)
            elif err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
                Dialog.notification('MySQL/MariaDB', getString(30225),
                                    xbmcgui.NOTIFICATION_ERROR)
            elif err.errno == errorcode.ER_BAD_DB_ERROR:
                mysql_config['database'] = None
                cnx = mysql.connector.connect(**mysql_config)
                c = cnx.cursor()
                cur_exec(
                    c,
                    'CREATE DATABASE %s CHARACTER SET utf8 COLLATE utf8_general_ci;'
                    % dbname)
                cnx.database = dbname
                createDatabase(cnx, dbname)
            else:
                Log(err)

    if not cnx:
        exit()
    return cnx
Example #14
0
def ADD_SHOW_ITEM(showdata,
                  mode='listtv',
                  submode='LIST_TV_SEASONS',
                  cmmode=0):
    asin, seriestitle, plot, network, mpaa, genres, actors, premiered, year, stars, votes, seasontotal, episodetotal, audio, isHD, isprime, empty, empty, empty, poster, banner, fanart = showdata
    infoLabels = {
        'Title': seriestitle,
        'Plot': plot,
        'mediatype': "tvshow",
        'MPAA': mpaa,
        'Cast': actors.split(',') if actors else None,
        'Year': year,
        'Premiered': premiered,
        'Rating': stars,
        'Votes': votes,
        'Genre': genres,
        'Episode': episodetotal,
        'TotalSeasons': seasontotal,
        'Studio': network,
        'AudioChannels': audio
    }
    infoLabels = {k: v for k, v in infoLabels.items() if v}
    submode = 'LIST_TV_SEASONS' if mode == 'listtv' else submode
    poster = '' if not poster else poster
    infoLabels['Thumb'] = poster
    infoLabels['Fanart'] = fanart
    infoLabels['Asins'] = asin
    asin = asin.split(',')[0]
    cm = []
    cm.append((
        common.getString(30180 + cmmode) % common.getString(30166),
        'XBMC.RunPlugin(%s?mode=<common>&sitemode=<toggleWatchlist>&asin=<%s>&remove=<%s>)'
        % (sys.argv[0], asin, cmmode)))
    cm.append((common.getString(
        30183
    ), 'Container.Update(%s?mode=<appfeed>&sitemode=<getSimilarities>&asin=<%s>)'
               % (sys.argv[0], asin)))
    cm.append((
        common.getString(30155) % common.getString(30166),
        'XBMC.RunPlugin(%s?mode=<tv>&sitemode=<delfromTVdb>&asins=<%s>&table=<shows>&title=<%s>)'
        % (sys.argv[0], urllib.quote_plus(
            infoLabels['Asins']), urllib.quote_plus(seriestitle))))
    common.addDir(seriestitle,
                  mode,
                  submode,
                  infoLabels['Asins'],
                  poster,
                  fanart,
                  infoLabels,
                  cm=cm)
Example #15
0
def SetupAmazonLibrary():
    common.Log('Trying to add Amazon source paths...')
    source_path = os.path.join(common.profilpath, 'sources.xml')
    source_added = False
    source = {'Amazon Movies': MOVIE_PATH, 'Amazon TV': TV_SHOWS_PATH}
    
    try:
        file = open(source_path)
        soup = BeautifulSoup(file)
        file.close()
    except:
        subtags = ['programs', 'video', 'music', 'pictures', 'files']
        soup = BeautifulSoup('<sources></sources>')
        root = soup.sources
        for cat in subtags:
            cat_tag = Tag(soup, cat)
            def_tag = Tag(soup, 'default')
            def_tag['pathversion'] = 1
            cat_tag.append(def_tag)
            root.append(cat_tag)

    video = soup.find("video")
    
    for name, path in source.items():
        path_tag = Tag(soup, "path")
        path_tag['pathversion'] = 1
        path_tag.append(path)
        source_text = soup.find(text=name)
        if not source_text:
            source_tag = Tag(soup, "source")
            name_tag = Tag(soup, "name")
            name_tag.append(name)
            source_tag.append(name_tag)
            source_tag.append(path_tag)
            video.append(source_tag)
            common.Log(name + ' source path added')
            source_added = True
        else:
            source_tag = source_text.findParent('source')
            old_path = source_tag.find('path').contents[0]
            if path not in old_path:
                source_tag.find('path').replaceWith(path_tag)
                common.Log(name + ' source path changed')
                source_added = True

    if source_added:
        SaveFile(source_path, str(soup))
        Dialog.ok(common.getString(30187), common.getString(30188), common.getString(30189), common.getString(30190))
        if Dialog.yesno(common.getString(30191), common.getString(30192)):
            xbmc.executebuiltin('RestartApp')
Example #16
0
def SEARCH_DB(searchString=False):
    if not searchString:
        keyboard = xbmc.Keyboard('')
        keyboard.doModal()
        if (keyboard.isConfirmed()):
            searchString = keyboard.getText()
            if searchString != '':
                common.addText('          ----=== ' + common.getString(30104) + ' ===----')
                if not listmovie.LIST_MOVIES('movietitle', searchString, search=True):
                    common.addText(common.getString(30202))
                common.addText('          ----=== ' + common.getString(30107) + ' ===----')
                if not listtv.LIST_TVSHOWS('seriestitle', searchString, search=True):
                    common.addText(common.getString(30202))
                common.SetView('tvshows')
Example #17
0
def LIST_TV_ROOT():
    common.addDir(common.getString(30100),'listtv','LIST_TVSHOWS_SORTED','popularity')
    common.addDir(common.getString(30110),'listtv','LIST_TVSEASON_SORTED','recent')
    common.addDir(common.getString(30149),'listtv','LIST_TVSHOWS_CATS')
    common.addDir(common.getString(30160),'listtv','LIST_TVSHOWS')
    common.addDir(common.getString(30144),'listtv','LIST_TVSHOWS_TYPES','genres' )
    common.addDir(common.getString(30158),'listtv','LIST_TVSHOWS_TYPES','actors')
    common.addDir(common.getString(30145),'listtv','LIST_TVSHOWS_TYPES','year' )
    common.addDir(common.getString(30161),'listtv','LIST_TVSHOWS_TYPES','network')
    common.addDir(common.getString(30162),'listtv','LIST_TVSHOWS_TYPES','mpaa' )
    xbmcplugin.endOfDirectory(pluginhandle)
Example #18
0
def SEARCH_DB(searchString=False):
    if not searchString:
        keyboard = xbmc.Keyboard('')
        keyboard.doModal()
        q = keyboard.getText()
        if (keyboard.isConfirmed()):
            searchString=keyboard.getText()
            if searchString <> '':
                common.addText('          ----=== ' + common.getString(30104) + ' ===----')
                if not listmovie.LIST_MOVIES('movietitle', searchString, search=True):
                    common.addText(common.getString(30202))
                common.addText('          ----=== ' + common.getString(30107) + ' ===----')
                if not listtv.LIST_TVSHOWS('seriestitle', searchString, search=True):
                    common.addText(common.getString(30202))
                common.SetView('tvshows', 'showview')
Example #19
0
def SEARCH_DB(searchString=False):
    if not searchString:
        keyboard = xbmc.Keyboard("")
        keyboard.doModal()
        q = keyboard.getText()
        if keyboard.isConfirmed():
            searchString = keyboard.getText()
            if searchString <> "":
                common.addText("          ----=== " + common.getString(30104) + " ===----")
                if not listmovie.LIST_MOVIES("movietitle", searchString, search=True):
                    common.addText(common.getString(30202))
                common.addText("          ----=== " + common.getString(30107) + " ===----")
                if not listtv.LIST_TVSHOWS("seriestitle", searchString, search=True):
                    common.addText(common.getString(30202))
                common.SetView("tvshows", "showview")
Example #20
0
def Error(data):
    code = data['errorCode']
    common.Log('%s (%s) ' %(data['message'], code), xbmc.LOGERROR)
    if 'CDP.InvalidRequest' in code:
        return common.getString(30204)
    elif 'CDP.Playback.NoAvailableStreams' in code:
        return common.getString(30205)
    elif 'CDP.Playback.NotOwned' in code:
        return common.getString(30206)
    elif 'CDP.Authorization.InvalidGeoIP' in code:
        return common.getString(30207)
    elif 'CDP.Playback.TemporarilyUnavailable' in code:
        return common.getString(30208)
    else:
        return '%s (%s) ' %(data['message'], code)
Example #21
0
def SEARCH_DB(searchString=None):
    if not searchString:
        keyboard = xbmc.Keyboard('', common.getString(24121))
        keyboard.doModal()
        if keyboard.isConfirmed():
            searchString = keyboard.getText()
            if searchString != '':
                common.addText('          ----=== ' + common.getString(30104) + ' ===----')
                if not listmovie.LIST_MOVIES('movietitle', searchString, search=True):
                    common.addText(common.getString(30202))
                common.addText('          ----=== ' + common.getString(30107) + ' ===----')
                if not listtv.LIST_TVSHOWS('seriestitle', searchString, search=True):
                    common.addText(common.getString(30202))
                common.SetView('tvshows', 'showview')
        xbmc.executebuiltin('Action(Close)')
Example #22
0
File: play.py Project: WhileE/xbmc
def Error(data):
    code = data['errorCode'].lower()
    common.Log('%s (%s) ' % (data['message'], code), xbmc.LOGERROR)
    if 'invalidrequest' in code:
        return common.getString(30204)
    elif 'noavailablestreams' in code:
        return common.getString(30205)
    elif 'notowned' in code:
        return common.getString(30206)
    elif 'invalidgeoip' in code:
        return common.getString(30207)
    elif 'temporarilyunavailable' in code:
        return common.getString(30208)
    else:
        return '%s (%s) ' % (data['message'], code)
Example #23
0
def ADD_EPISODE_ITEM(episodedata, onlyinfo=False, export=False):
    asin, seasonASIN, seriesASIN, seriestitle, season, episode, poster, mpaa, actors, genres, episodetitle, network, \
        stars, votes, fanart, plot, airdate, year, runtime, isHD, isprime, isAdult, audio = episodedata
    tvfanart, tvposter = getFanart(seriesASIN)
    fanart = tvfanart if showfanart else fanart
    displayname = "{} - {}".format(episode, episodetitle).replace('"', '')
    if episode == 0 and ':' in episodetitle:
        displayname = '- ' + episodetitle.split(':')[1].strip() + ' -'

    infoLabels = {'Title': displayname,
                  'TVShowTitle': seriestitle,
                  'Episode': episode,
                  'mediatype': 'episode',
                  'Season': season,
                  'Plot': plot,
                  'Premiered': airdate,
                  'Year': year,
                  'Duration': int(runtime) * 60 if runtime else None,
                  'MPAA': mpaa if mpaa else common.getString(30171),
                  'Cast': actors.split(',') if actors else [],
                  'Rating': stars,
                  'Votes': votes,
                  'Genre': genres,
                  'Studio': network,
                  'AudioChannels': audio,
                  'isAdult': isAdult,
                  'Thumb': poster,
                  'Fanart': fanart,
                  'isHD': isHD,
                  'seriesASIN': seriesASIN,
                  'Poster': tvposter
                  }
    asin = asin.split(',')[0]

    if export:
        xbmclibrary.EXPORT_EPISODE(asin)
        return

    cm = [(common.getString(30185) % common.getString(30173),
           'RunPlugin(%s?mode=<xbmclibrary>&sitemode=<EXPORT_EPISODE>&asin=<%s>)' % (sys.argv[0], asin)),
          (common.getString(30183),
           'Container.Update(%s?mode=<appfeed>&sitemode=<getSimilarities>&asin=<%s>)' % (sys.argv[0], asin)),
          (common.getString(30186), 'RunPlugin(%s?mode=<xbmclibrary>&sitemode=<UpdateLibrary>)' % sys.argv[0])]

    if onlyinfo:
        return infoLabels
    else:
        common.addVideo(displayname, asin, poster, fanart, infoLabels=infoLabels, isAdult=isAdult, isHD=isHD, cm=cm)
Example #24
0
def delfromTVdb():
    asins = common.args.asins
    title = common.args.title
    table = common.args.table
    id = 30166
    if table == 'seasons': id = 30167

    if Dialog.yesno(common.getString(30155) % common.getString(id), common.getString(30156) % title.decode('utf-8')):
        delasins = []
        if table == 'seasons':
            delasins.append(asins)
        else:
            for asin in asins.split(','):
                for item in lookupTVdb(asin, rvalue='asin', tbl='seasons', name='seriesasin'):
                    if item: delasins += (item)
        UpdateDialog(0, 0, 0, *deleteremoved(delasins))
Example #25
0
def RefreshList():
    import tv
    import movies
    list_ = common.args.url
    mvlist = []
    tvlist = []
    pDialog = xbmcgui.DialogProgress()
    pDialog.create(common.__plugin__, common.getString(30117))

    for asin in common.SCRAP_ASINS(common.movielib % list_):
        if not movies.lookupMoviedb(asin):
            mvlist.append(asin)

    for asin in common.SCRAP_ASINS(common.tvlib % list_):
        if not tv.lookupTVdb(asin, tbl='seasons'):
            tvlist.append(asin)

    if mvlist:
        movies.updateLibrary(mvlist)
    if tvlist:
        tv.addTVdb(False, tvlist)
    pDialog.close()

    if mvlist:
        movies.updateFanart()
    if tvlist:
        tv.updateFanart()
Example #26
0
def RefreshList():
    cj = common.mechanizeLogin()
    if not cj:
        return

    import tv
    import movies
    l = common.args.url
    mvlist = []
    tvlist = []
    pDialog = xbmcgui.DialogProgress()
    pDialog.create(common.__plugin__, common.getString(30117))

    for asin in common.SCRAP_ASINS(common.movielib % l, cj):
        if not movies.lookupMoviedb(asin):
            mvlist.append(asin)

    for asin in common.SCRAP_ASINS(common.tvlib % l, cj):
        if not tv.lookupTVdb(asin, tbl='seasons'):
            tvlist.append(asin)

    if mvlist:
        movies.updateLibrary(mvlist)

    if tvlist:
        tv.addTVdb(False, tvlist, None)

    pDialog.close()

    if mvlist:
        movies.updateFanart()

    if tvlist:
        tv.updateFanart()
Example #27
0
def ADD_EPISODE_ITEM(episodedata):
    asin, seasonASIN, seriesASIN, seriestitle, season, episode, poster, mpaa, actors, genres, episodetitle, network, stars, votes, fanart, plot, airdate, year, runtime, isHD, isprime, isAdult, audio = episodedata
    tvfanart, tvposter = getFanart(seriesASIN)
    fanart = tvfanart if showfanart else fanart
    displayname = "{} - {}".format(episode, episodetitle).replace('"', '')
    infoLabels = {'Title': episodetitle,
                  'TVShowTitle': seriestitle,
                  'Episode': episode,
                  'mediatype': "episode",
                  'Season': season,
                  'Plot': plot,
                  'Premiered': airdate,
                  'Year': year,
                  'Duration': int(runtime) * 60 if runtime else None,
                  'MPAA': mpaa,
                  'Cast': actors.split(',') if actors else None,
                  'Rating': stars,
                  'Votes': votes,
                  'Genre': genres,
                  'Studio': network,
                  'AudioChannels': audio,
                  'isAdult': isAdult,
                  'isHD': isHD,
                  'seriesASIN': seriesASIN,
                  }
    infoLabels = {k: v for k, v in infoLabels.items() if v}
    infoLabels['Fanart'] = fanart
    infoLabels['Thumb'] = poster
    infoLabels['Poster'] = tvposter
    asin = asin.split(',')[0]
    cm = [(common.getString(30183), 'Container.Update(%s?mode=<appfeed>&sitemode=<getSimilarities>&asin=<%s>)' % (sys.argv[0], asin))]
    common.addVideo(displayname, asin, poster, fanart, infoLabels=infoLabels, isAdult=isAdult, isHD=isHD, cm=cm)
Example #28
0
File: play.py Project: WhileE/xbmc
def PLAYVIDEO():
    amazonUrl = common.BASE_URL + "/dp/" + common.args.asin
    waitsec = int(addon.getSetting("clickwait")) * 1000
    pin = addon.getSetting("pin")
    waitpin = int(addon.getSetting("waitpin")) * 1000
    waitprepin = int(addon.getSetting("waitprepin")) * 1000
    trailer = common.args.trailer == '1'
    isAdult = int(common.args.adult) == '1'
    pininput = addon.getSetting("pininput") == 'true'
    fullscr = addon.getSetting("fullscreen") == 'true'

    if trailer:
        videoUrl = amazonUrl + "/?autoplaytrailer=1"
    else:
        videoUrl = amazonUrl + "/?autoplay=1"

    if playMethod == 2 or platform == osAndroid:
        AndroidPlayback(common.args.asin, trailer)
    elif playMethod == 3:
        IStreamPlayback(trailer, isAdult)
    else:
        if common.verbLog:
            videoUrl += '&playerDebug=true'

        url, err = getCmdLine(videoUrl)
        if not url:
            Dialog.notification(common.getString(30203), err, xbmcgui.NOTIFICATION_ERROR)
            return
        common.Log('Executing: %s' % url)
        if platform == 1:
            process = subprocess.Popen(url, startupinfo=getStartupInfo())
        else:
            process = subprocess.Popen(url, shell=True)

        if isAdult and pininput:
            if fullscr:
                waitsec *= 0.75
            else:
                waitsec = waitprepin
            xbmc.sleep(int(waitsec))
            Input(keys=pin)
            waitsec = waitpin

        if fullscr:
            xbmc.sleep(int(waitsec))
            if browser != 0:
                Input(keys='f')
            else:
                Input(mousex=-1, mousey=350, click=2)
                xbmc.sleep(500)
                Input(mousex=9999, mousey=350)

        Input(mousex=9999, mousey=-1)

        if hasExtRC:
            return

        myWindow = window()
        myWindow.wait(process)
Example #29
0
File: play.py Project: sbeatz/xbmc
def GETLANG(suc, rtmpdata):
    if not suc:
        return False, rtmpdata
    langid = []
    langname = []
    try:
        format = rtmpdata['titles'][0]['formats'][0]
        for lang in format['audioTrackLanguageList']['audioTrackLanguage'][0]['audioLanguageList']['audioLanguage']:
            langid.append(lang['audioFormatAssetList']['audioFormatAsset'][0]['audioTrackId'])
            langname.append(lang['language']['displayName'])
    except:
        langname.append(common.getString(30209))
        langid.append('')
    lang = Dialog.select(common.getString(30115), langname)
    if lang > -1:
        return True, '&audioTrackId=' + langid[lang]
    return False, False
Example #30
0
def updateAll():
    import movies
    import tv
    from datetime import datetime
    common.addon.setSetting('update_running', datetime.today().strftime('%Y-%m-%d %H:%M'))
    Notif = xbmcgui.Dialog().notification
    Notif(common.__plugin__, common.getString(30106), sound = False)
    tv.addTVdb(full_update = False)
    movies.addMoviesdb(full_update = False)
    NewAsins = common.getNewest()
    movies.setNewest(NewAsins)
    movies.updateFanart()
    tv.setNewest(NewAsins)
    tv.updateFanart()
    common.addon.setSetting('last_update', datetime.today().strftime('%Y-%m-%d'))
    common.addon.setSetting('update_running', 'false')
    Notif(common.__plugin__, common.getString(30126), sound = False)
Example #31
0
def loadSQLconfig():
    keys = 'host port user pass'
    userdata = xbmc.translatePath('special://userdata').decode('utf-8')
    asfile = os.path.join(userdata, 'advancedsettings.xml')
    if xbmcvfs.exists(asfile):
        f = xbmcvfs.File(asfile, 'r')
        soup = BeautifulSoup(f.read(),
                             convertEntities=BeautifulSoup.XML_ENTITIES)
        videodb = soup.advancedsettings.videodatabase
        if videodb:
            for tag in videodb.findAll():
                if tag.name in keys:
                    addon.setSetting('db' + tag.name, tag.string)
        else:
            Dialog.notification(pluginname, getString(30226))
    else:
        Dialog.notification(pluginname, getString(30226))
Example #32
0
def ADD_MOVIE_ITEM(moviedata, onlyinfo=False, cmmode=0, export=False):
    asin, hd_asin, movietitle, trailer, poster, plot, director, writer, runtime, year, premiered, studio, mpaa, actors,\
     genres, stars, votes, fanart, isprime, isHD, isAdult, popularity, recent, audio = moviedata
    infoLabels = {'Title': movietitle,
                  'Plot': plot,
                  'mediatype': "movie",
                  'Cast': actors.split(',') if actors else [],
                  'Director': director,
                  'Year': year,
                  'Premiered': premiered,
                  'Rating': stars,
                  'Votes': votes,
                  'Genre': genres,
                  'MPAA': mpaa if mpaa else common.getString(30171),
                  'Studio': studio,
                  'Duration': int(runtime) * 60 if runtime else None,
                  'AudioChannels': audio,
                  'Thumb': poster,
                  'Fanart': fanart,
                  'isHD': isHD,
                  'isAdult': isAdult}
    asin = asin.split(',')[0]
    if export:
        xbmclibrary.EXPORT_MOVIE(asin)
        return
    cm = [(common.getString(30180 + cmmode) % common.getString(30154),
          'RunPlugin(%s?mode=<common>&sitemode=<toogleWatchlist>&asin=<%s>&remove=<%s>)' % (sys.argv[0], asin, cmmode)),
          (common.getString(30185) % common.getString(30154),
          'RunPlugin(%s?mode=<xbmclibrary>&sitemode=<EXPORT_MOVIE>&asin=<%s>)' % (sys.argv[0], asin)),
          (common.getString(30183), 'Container.Update(%s?mode=<appfeed>&sitemode=<getSimilarities>&asin=<%s>)' % (sys.argv[0], asin)),
          (common.getString(30186), 'RunPlugin(%s?mode=<xbmclibrary>&sitemode=<UpdateLibrary>)' % sys.argv[0])]
    if onlyinfo:
        return infoLabels
    else:
        common.addVideo(movietitle, asin, poster, fanart, infoLabels=infoLabels, cm=cm, trailer=trailer, isAdult=isAdult, isHD=isHD)
Example #33
0
File: play.py Project: sbeatz/xbmc
def GETFLASHVARS(pageurl):
    cookie = common.mechanizeLogin()
    showpage = common.getURL(pageurl, useCookie=cookie)
    common.WriteLog(showpage, 'flashvars', 'w')
    if not showpage:
        Dialog.notification(common.__plugin__, Error('CDP.InvalidRequest'), xbmcgui.NOTIFICATION_ERROR)
        return False
    values = {}
    search = {'asin'       : '"pageAsin":"(.*?)"',
              'sessionID'  : "ue_sid='(.*?)'",
              'marketplace': "ue_mid='(.*?)'",
              'customer'   : '"customerID":"(.*?)"'}
    if 'var config' in showpage:
        flashVars = re.compile('var config = (.*?);',re.DOTALL).findall(showpage)
        flashVars = demjson.decode(unicode(flashVars[0], errors='ignore'))
        values = flashVars['player']['fl_config']['initParams']
        swfUrl = flashVars['player']['fl_config']['playerSwf']
    else:
        for key, pattern in search.items():
            result = re.compile(pattern, re.DOTALL).findall(showpage)
            if result: values[key] = result[0]
        values['swfUrl'] = 'http://ecx.images-amazon.com/images/G/01/digital/video/webplayer/1.0.379.0/swf/UnboxScreeningRoomClient.swf'
    
    for key in values.keys():
        if not values.has_key(key):
            Dialog.notification(common.getString(30200), common.getString(30210), xbmcgui.NOTIFICATION_ERROR)
            return False

    values['deviceTypeID']  = 'A324MFXUEZFF7B' #Sony GoogleTV unenc Flash
    #values['deviceTypeID']  = 'A13Q6A55DBZB7M' #enc Flash
    #values['deviceTypeID']  = 'A35LWR0L7KC0TJ' #Logitech GoogleTV unenc Flash
    #values['deviceTypeID']  = 'A63V4FRV3YUP9' #enc Silverlight
    values['userAgent']     = "GoogleTV 162671"
    values['deviceID']      = common.hmac.new(common.UserAgent, common.gen_id(), hashlib.sha224).hexdigest()
    rand = 'onWebToken_' + str(random.randint(0,484))
    pltoken = common.getURL(common.BASE_URL + "/gp/video/streaming/player-token.json?callback=" + rand, useCookie=cookie)
    try:
        values['token']  = re.compile('"([^"]*).*"([^"]*)"').findall(pltoken)[0][1]
    except:
        Dialog.notification(common.getString(30200), common.getString(30201), xbmcgui.NOTIFICATION_ERROR)
        return False
    return values
Example #34
0
def updateAll():
    if common.updateRunning(): return
    import movies
    import tv
    from datetime import datetime
    common.addon.setSetting('update_running', datetime.today().strftime('%Y-%m-%d %H:%M'))
    common.Log('Starting DBUpdate')
    Notif = xbmcgui.Dialog().notification
    Notif(common.__plugin__, common.getString(30106), sound = False)
    tv.addTVdb(False)
    movies.addMoviesdb(False)
    NewAsins = common.getCategories()
    movies.setNewest(NewAsins)
    movies.updateFanart()
    tv.setNewest(NewAsins)
    tv.updateFanart()
    common.addon.setSetting('last_update', datetime.today().strftime('%Y-%m-%d'))
    common.addon.setSetting('update_running', 'false')
    Notif(common.__plugin__, common.getString(30126), sound = False)
    common.Log('DBUpdate finished')
Example #35
0
def LIST_MOVIE_ROOT():
    common.addDir(common.getString(30100), 'listmovie', 'LIST_MOVIES_SORTED',
                  'popularity')
    common.addDir(common.getString(30110), 'listmovie', 'LIST_MOVIES_SORTED',
                  'recent')
    common.addDir(common.getString(30149), 'listmovie', 'LIST_MOVIES_CATS')
    common.addDir(common.getString(30143), 'listmovie', 'LIST_MOVIES')
    common.addDir(common.getString(30144), 'listmovie', 'LIST_MOVIE_TYPES',
                  'genres')
    common.addDir(common.getString(30145), 'listmovie', 'LIST_MOVIE_TYPES',
                  'year')
    common.addDir(common.getString(30146), 'listmovie', 'LIST_MOVIE_TYPES',
                  'studio')
    common.addDir(common.getString(30158), 'listmovie', 'LIST_MOVIE_TYPES',
                  'actors')
    common.addDir(common.getString(30147), 'listmovie', 'LIST_MOVIE_TYPES',
                  'mpaa')
    common.addDir(common.getString(30148), 'listmovie', 'LIST_MOVIE_TYPES',
                  'director')
    xbmcplugin.endOfDirectory(pluginhandle)
Example #36
0
def ADD_MOVIE_ITEM(moviedata, cmmode=0):
    asin, hd_asin, movietitle, trailer, poster, plot, director, writer, runtime, year, premiered, studio, mpaa, actors, genres, stars, votes, fanart, isprime, isHD, isAdult, popularity, recent, audio = moviedata
    infoLabels = {
        'Title': movietitle,
        'Plot': plot,
        'mediatype': "movie",
        'Cast': actors.split(',') if actors else [],
        'Director': director,
        'Year': year,
        'Premiered': premiered,
        'Rating': stars,
        'Votes': votes,
        'Genre': genres,
        'mpaa': mpaa,
        'Studio': studio,
        'Duration': int(runtime) * 60,
        'AudioChannels': audio,
        'Thumb': poster,
        'Fanart': fanart,
        'isHD': isHD,
        'isAdult': isAdult
    }
    asin = asin.split(',')[0]
    cm = []
    cm.append((
        common.getString(30180 + cmmode) % common.getString(30154),
        'XBMC.RunPlugin(%s?mode=<common>&sitemode=<toggleWatchlist>&asin=<%s>&remove=<%s>)'
        % (sys.argv[0], asin, cmmode)))
    cm.append((common.getString(
        30183
    ), 'Container.Update(%s?mode=<appfeed>&sitemode=<getSimilarities>&asin=<%s>)'
               % (sys.argv[0], asin)))
    common.addVideo(movietitle,
                    asin,
                    poster,
                    fanart,
                    infoLabels=infoLabels,
                    cm=cm,
                    trailer=trailer,
                    isAdult=isAdult,
                    isHD=isHD)
Example #37
0
File: play.py Project: WhileE/xbmc
def IStreamPlayback(trailer, isAdult):
    values = getFlashVars()
    if not values:
        return

    infoLabels = GetStreamInfo(common.args.asin)
    mpaa_str = common.RestrAges + common.getString(30171)
    mpaa_check = infoLabels.get('MPAA', mpaa_str) in mpaa_str or isAdult
    vMT = 'Trailer' if trailer else 'Feature'

    mpd, subs = getStreams(*getUrldata('catalog/GetPlaybackResources', values, extra=True, vMT=vMT,
                                       opt='&titleDecorationScheme=primary-content'), retmpd=True)
    licURL = getUrldata('catalog/GetPlaybackResources', values, extra=True, vMT=vMT, dRes='Widevine2License',
                        retURL=True)
    common.Log(mpd)
    if not mpd:
        Dialog.notification(common.getString(30203), subs, xbmcgui.NOTIFICATION_ERROR)
        return

    if mpaa_check and not common.RequestPin():
        return

    listitem = xbmcgui.ListItem(path=mpd)
    if trailer:
        infoLabels['Title'] += ' (Trailer)'
    if 'Thumb' not in infoLabels.keys():
        infoLabels['Thumb'] = None
    if 'Fanart' in infoLabels.keys():
        listitem.setArt({'fanart': infoLabels['Fanart']})
    if 'Poster' in infoLabels.keys():
        listitem.setArt({'tvshow.poster': infoLabels['Poster']})
    else:
        listitem.setArt({'poster': infoLabels['Thumb']})

    listitem.setArt({'thumb': infoLabels['Thumb']})
    listitem.setInfo('video', infoLabels)
    listitem.setSubtitles(subs)
    listitem.setProperty('inputstream.mpd.license_type', 'com.widevine.alpha')
    listitem.setProperty('inputstream.mpd.license_key', licURL)
    listitem.setProperty('inputstreamaddon', 'inputstream.mpd')
    xbmcplugin.setResolvedUrl(pluginhandle, True, listitem=listitem)
Example #38
0
def delfromTVdb():
    asins = common.args.asins
    title = common.args.title
    table = common.args.table
    string_id = 30166
    if table == 'seasons':
        string_id = 30167

    if Dialog.yesno(common.getString(30155) % common.getString(string_id), common.getString(30156) % title.decode('utf-8')):
        delasins = []
        if table == 'seasons':
            delasins.append(asins)
        else:
            for asin in asins.split(','):
                for item in lookupTVdb(value=asin,
                                       rvalue='asin',
                                       tbl='seasons',
                                       name='seriesasin'):
                    if item:
                        delasins += (item)
        UpdateDialog(0, 0, 0, *deleteremoved(delasins))
Example #39
0
def LIST_TV_ROOT():
    common.addDir(common.getString(30100), 'listtv', 'LIST_TVSHOWS_SORTED',
                  'popularity')
    common.addDir(common.getString(30110), 'listtv', 'LIST_TVSEASON_SORTED',
                  'recent')
    common.addDir(common.getString(30149), 'listtv', 'LIST_TVSHOWS_CATS')
    common.addDir(common.getString(30160), 'listtv', 'LIST_TVSHOWS')
    common.addDir(common.getString(30144), 'listtv', 'LIST_TVSHOWS_TYPES',
                  'genres')
    common.addDir(common.getString(30158), 'listtv', 'LIST_TVSHOWS_TYPES',
                  'actors')
    common.addDir(common.getString(30145), 'listtv', 'LIST_TVSHOWS_TYPES',
                  'year')
    common.addDir(common.getString(30161), 'listtv', 'LIST_TVSHOWS_TYPES',
                  'network')
    common.addDir(common.getString(30162), 'listtv', 'LIST_TVSHOWS_TYPES',
                  'mpaa')
    xbmcplugin.endOfDirectory(pluginhandle)
Example #40
0
def updateAll():
    if common.updateRunning():
        return
    import movies
    import tv
    from datetime import datetime

    common.addon.setSetting("update_running", datetime.today().strftime("%Y-%m-%d %H:%M"))
    common.Log("Starting DBUpdate")
    Notif = xbmcgui.Dialog().notification
    Notif(common.__plugin__, common.getString(30106), sound=False)
    tv.addTVdb(False)
    movies.addMoviesdb(False)
    NewAsins = common.getCategories()
    movies.setNewest(NewAsins)
    movies.updateFanart()
    tv.setNewest(NewAsins)
    tv.updateFanart()
    common.addon.setSetting("last_update", datetime.today().strftime("%Y-%m-%d"))
    common.addon.setSetting("update_running", "false")
    Notif(common.__plugin__, common.getString(30126), sound=False)
    common.Log("DBUpdate finished")
Example #41
0
def ADD_SHOW_ITEM(showdata,mode='listtv',submode='LIST_TV_SEASONS',cmmode=0,onlyinfo=False,export=False):
    asin,seriestitle,plot,network,mpaa,genres,actors,premiered,year,stars,votes,seasontotal,episodetotal,audio,isHD,isprime,empty,empty,empty,poster,banner,fanart = showdata
    infoLabels={'Title': seriestitle,'TVShowTitle':seriestitle}
    if plot:
        infoLabels['Plot'] = plot
    if mpaa:
        infoLabels['MPAA'] = mpaa
    if actors:
        infoLabels['Cast'] = actors.split(',')
    if year:
        infoLabels['Year'] = year
    if premiered:
        infoLabels['Premiered'] = premiered
    if stars:
        infoLabels['Rating'] = stars           
    if votes:
        infoLabels['Votes'] = votes  
    if genres:
        infoLabels['Genre'] = genres 
    if episodetotal:
        infoLabels['Episode'] = episodetotal
    if seasontotal:
        infoLabels['TotalSeasons'] = seasontotal
    if network:
        infoLabels['Studio'] = network
    if audio:
        infoLabels['AudioChannels'] = audio
    if mode == 'listtv':
        submode = 'LIST_TV_SEASONS'
    if poster is None:
        poster=''
    infoLabels['Thumb'] = poster
    infoLabels['Fanart'] = fanart
    infoLabels['Asins'] = asin
    asin = asin.split(',')[0]
    if export:
        xbmclibrary.EXPORT_SHOW(asin)
        return
    cm = []
    cm.append((common.getString(30180+cmmode) % common.getString(30166), 'XBMC.RunPlugin(%s?mode=<common>&sitemode=<toogleWatchlist>&asin=<%s>&remove=<%s>)' % (sys.argv[0], asin, cmmode)))
    cm.append((common.getString(30185) % common.getString(30166), 'XBMC.RunPlugin(%s?mode=<xbmclibrary>&sitemode=<EXPORT_SHOW>&asin=<%s>)' % (sys.argv[0], asin)))
    cm.append((common.getString(30183), 'Container.Update(%s?mode=<appfeed>&sitemode=<getSimilarities>&asin=<%s>)' % (sys.argv[0], asin)))
    cm.append((common.getString(30186), 'XBMC.RunPlugin(%s?mode=<xbmclibrary>&sitemode=<UpdateLibrary>)' % sys.argv[0]))
    cm.append((common.getString(30155) % common.getString(30166), 'XBMC.RunPlugin(%s?mode=<tv>&sitemode=<delfromTVdb>&asins=<%s>&table=<shows>&title=<%s>)' % ( sys.argv[0], urllib.quote_plus(infoLabels['Asins']), urllib.quote_plus(seriestitle))))
    if onlyinfo:
        return infoLabels
    else:
        common.addDir(seriestitle,mode,submode,infoLabels['Asins'],poster,fanart,infoLabels,isHD=isHD,cm=cm)
Example #42
0
def getFlashVars(url):
    cookie = common.mechanizeLogin()
    showpage = common.getURL(url, useCookie=cookie)
    #common.WriteLog(showpage, 'flashvars', 'w')
    if not showpage:
        Dialog.notification(common.__plugin__, Error('CDP.InvalidRequest'), xbmcgui.NOTIFICATION_ERROR)
        return False
    values = {}
    search = {'asin'       : '"pageAsin":"(.*?)"',
              'sessionID'  : "ue_sid='(.*?)'",
              'marketplace': "ue_mid='(.*?)'",
              'customer'   : '"customerID":"(.*?)"'}
    if 'var config' in showpage:
        flashVars = re.compile('var config = (.*?);',re.DOTALL).findall(showpage)
        flashVars = json.loads(unicode(flashVars[0], errors='ignore'))
        values = flashVars['player']['fl_config']['initParams']
    else:
        for key, pattern in search.items():
            result = re.compile(pattern, re.DOTALL).findall(showpage)
            if result: values[key] = result[0]
    
    for key in values.keys():
        if not values.has_key(key):
            Dialog.notification(common.getString(30200), common.getString(30210), xbmcgui.NOTIFICATION_ERROR)
            return False

    values['deviceTypeID']  = 'AOAGZA014O5RE'
    values['userAgent']     = common.UserAgent
    values['deviceID']      = common.hmac.new(common.UserAgent, common.gen_id(), hashlib.sha224).hexdigest()
    rand = 'onWebToken_' + str(random.randint(0,484))
    pltoken = common.getURL(common.BASE_URL + "/gp/video/streaming/player-token.json?callback=" + rand, useCookie=cookie)
    try:
        values['token']  = re.compile('"([^"]*).*"([^"]*)"').findall(pltoken)[0][1]
    except:
        Dialog.notification(common.getString(30200), common.getString(30201), xbmcgui.NOTIFICATION_ERROR)
        return False
    return values
Example #43
0
def SetupAmazonLibrary():
    common.Log('Trying to add Amazon source paths...')
    source_path = os.path.join(common.profilpath, 'sources.xml')
    source_added = False
    source = {'Amazon Movies': MOVIE_PATH, 'Amazon TV': TV_SHOWS_PATH}

    try:
        file = open(source_path)
        soup = BeautifulSoup(file)
        file.close()
    except:
        subtags = ['programs', 'video', 'music', 'pictures', 'files']
        soup = BeautifulSoup('<sources></sources>')
        root = soup.sources
        for cat in subtags:
            cat_tag = Tag(soup, cat)
            def_tag = Tag(soup, 'default')
            def_tag['pathversion'] = 1
            cat_tag.append(def_tag)
            root.append(cat_tag)

    video = soup.find("video")

    for name, path in source.items():
        path_tag = Tag(soup, "path")
        path_tag['pathversion'] = 1
        path_tag.append(path)
        source_text = soup.find(text=name)
        if not source_text:
            source_tag = Tag(soup, "source")
            name_tag = Tag(soup, "name")
            name_tag.append(name)
            source_tag.append(name_tag)
            source_tag.append(path_tag)
            video.append(source_tag)
            common.Log(name + ' source path added')
            source_added = True
        else:
            source_tag = source_text.findParent('source')
            old_path = source_tag.find('path').contents[0]
            if path not in old_path:
                source_tag.find('path').replaceWith(path_tag)
                common.Log(name + ' source path changed')
                source_added = True

    if source_added:
        SaveFile(source_path, str(soup))
        Dialog.ok(common.getString(30187), common.getString(30188),
                  common.getString(30189), common.getString(30190))
        if Dialog.yesno(common.getString(30191), common.getString(30192)):
            xbmc.executebuiltin('RestartApp')
Example #44
0
def ADD_EPISODE_ITEM(episodedata):
    asin, seasonASIN, seriesASIN, seriestitle, season, episode, poster, mpaa, actors, genres, episodetitle, network, stars, votes, fanart, plot, airdate, year, runtime, isHD, isprime, isAdult, audio = episodedata
    tvfanart, tvposter = getFanart(seriesASIN)
    fanart = tvfanart if showfanart else fanart
    displayname = "{} - {}".format(episode, episodetitle).replace('"', '')
    infoLabels = {
        'Title': episodetitle,
        'TVShowTitle': seriestitle,
        'Episode': episode,
        'mediatype': "episode",
        'Season': season,
        'Plot': plot,
        'Premiered': airdate,
        'Year': year,
        'Duration': int(runtime) * 60 if runtime else None,
        'MPAA': mpaa,
        'Cast': actors.split(',') if actors else None,
        'Rating': stars,
        'Votes': votes,
        'Genre': genres,
        'Studio': network,
        'AudioChannels': audio,
        'isAdult': isAdult,
        'isHD': isHD,
        'seriesASIN': seriesASIN,
    }
    infoLabels = {k: v for k, v in infoLabels.items() if v}
    infoLabels['Fanart'] = fanart
    infoLabels['Thumb'] = poster
    infoLabels['Poster'] = tvposter
    asin = asin.split(',')[0]
    cm = [(common.getString(
        30183
    ), 'Container.Update(%s?mode=<appfeed>&sitemode=<getSimilarities>&asin=<%s>)'
           % (sys.argv[0], asin))]
    common.addVideo(displayname,
                    asin,
                    poster,
                    fanart,
                    infoLabels=infoLabels,
                    isAdult=isAdult,
                    isHD=isHD,
                    cm=cm)
Example #45
0
def ListCont(export=False):
    import tv
    mov = False
    showonly = False
    rvalue = 'distinct *'
    if export:
        url = export
        export = True
    else: url = common.args.url
    if 'movie' in url: mov = True
    if common.addon.getSetting('disptvshow') == 'true':
        showonly = True
        rvalue = 'seriesasin'
    asins = common.SCRAP_ASINS(url)
    if not asins:
        xbmcgui.Dialog().notification(common.__plugin__, common.getString(30199), sound = False)
        return

    asinlist = []
    for value in asins:
        ret = 0
        if mov: ret = listmovie.LIST_MOVIES('asin', value, search=True, cmmode=1, export=export)
        if ret == 0 and not mov:
            for seasondata in tv.lookupTVdb(value, tbl='seasons', rvalue=rvalue, single=False):
                if seasondata:
                    if showonly:
                        ret = 0
                        value = seasondata[0]
                        for asin in tv.lookupTVdb(value, tbl='shows', rvalue='asin').split(','):
                            if asin in asinlist: ret = 1
                    else:
                        ret = 1
                        listtv.ADD_SEASON_ITEM(seasondata, disptitle=True, cmmode=1, export=export)
        if ret == 0 and not mov: listtv.LIST_TVSHOWS('asin', value, search=True, cmmode=1, export=export)
        asinlist.append(value)

    if not export:
        if mov: common.SetView('movies', 'movieview')
        else: common.SetView('tvshows', 'showview')
Example #46
0
def ASIN_ADD(titles, asins=False):
    if asins:
        titles = appfeed.ASIN_LOOKUP(asins)['message']['body']['titles']
    count = 0
    for title in titles:
        poster = plot = premiered = year = studio = mpaa = fanart = imdburl = None
        actors = genres = stars = votes = seriesasin = runtime = None
        seasontotal = episodetotal = episode = 0
        isAdult = False
        if asins:
            contentType = 'SERIES'
        else:
            contentType = title['contentType']

        asin, isHD, isPrime, audio = common.GET_ASINS(title)
        if 'images' in title['formats'][0]:
            try:
                thumbnailUrl = title['formats'][0]['images'][0]['uri']
                thumbnailFilename = thumbnailUrl.split('/')[-1]
                thumbnailBase = thumbnailUrl.replace(thumbnailFilename, '')
                poster = thumbnailBase + thumbnailFilename.split('.')[0] + '.jpg'
            except Exception:
                pass
        plot = title.get('synopsis')
        if 'releaseOrFirstAiringDate' in title:
            premiered = title['releaseOrFirstAiringDate']['valueFormatted'].split('T')[0]
            year = int(premiered.split('-')[0])
        studio = title.get('studioOrNetwork')
        if 'regulatoryRating' in title:
            if title['regulatoryRating'] == 'not_checked':
                mpaa = common.getString(30171)
            else:
                mpaa = common.getString(30170) + title['regulatoryRating']
        actors = title.get('starringCast')
        if 'genres' in title:
            genres = ' / '.join(title['genres']).replace('_', ' & ').replace('Musikfilm & Tanz', 'Musikfilm, Tanz')
        if 'customerReviewCollection' in title:
            stars = float(title['customerReviewCollection']['customerReviewSummary']['averageOverallRating']) * 2
            votes = str(title['customerReviewCollection']['customerReviewSummary']['totalReviewCount'])
        elif 'amazonRating' in title:
            if 'rating' in title['amazonRating']:
                stars = float(title['amazonRating']['rating']) * 2
            if 'count' in title['amazonRating']:
                votes = str(title['amazonRating']['count'])
        fanart = title.get('heroUrl')
        if contentType == 'SERIES':
            seriestitle = title['title']
            if 'childTitles' in title:
                seasontotal = title['childTitles'][0]['size']
            showdata = [common.cleanData(x) for x in [asin, common.checkCase(seriestitle), plot, studio, mpaa, genres, actors, premiered, year, stars, votes, seasontotal, 0, audio, isHD, isPrime, None, None, None, poster, None, fanart]]
            count += addDB('shows', showdata)
        elif contentType == 'SEASON':
            season = title['number']
            if title['ancestorTitles']:
                try:
                    seriestitle = title['ancestorTitles'][0]['title']
                    seriesasin = title['ancestorTitles'][0]['titleId']
                except Exception:
                    pass
            else:
                seriesasin = asin.split(',')[0]
                seriestitle = title['title']
            if 'childTitles' in title:
                episodetotal = title['childTitles'][0]['size']
            # if title.has_key('drakeUrl'):
            #    imdburl = title['drakeUrl']
            imdburl = title.get('imdbUrl')
            seasondata = [common.cleanData(x) for x in [asin, seriesasin, season, common.checkCase(seriestitle), plot, actors, studio, mpaa, genres, premiered, year, stars, votes, episodetotal, audio, None, None, isHD, isPrime, imdburl, poster, None, fanart]]
            count += addDB('seasons', seasondata)
        elif contentType == 'EPISODE':
            episodetitle = title['title']
            if 'ancestorTitles' in title:
                for content in title['ancestorTitles']:
                    if content['contentType'] == 'SERIES':
                        seriesasin = content.get('titleId')
                        seriestitle = content.get('title')
                    elif content['contentType'] == 'SEASON':
                        season = content.get('number')
                        seasonasin = content.get('titleId')
                        seasontitle = content.get('title')
                if not seriesasin:
                    seriesasin = seasonasin
                    seriestitle = seasontitle
            episode = title.get('number')
            if 'runtime' in title:
                runtime = str(title['runtime']['valueMillis'] / 60000)
            if 'restrictions' in title:
                for rest in title['restrictions']:
                    if rest['action'] == 'playback':
                        if rest['type'] == 'ageVerificationRequired':
                            isAdult = True
            episodedata = [common.cleanData(x) for x in [asin, seasonasin, seriesasin, common.checkCase(seriestitle), season, episode, poster, mpaa, actors, genres, common.checkCase(episodetitle), studio, stars, votes, fanart, plot, premiered, year, runtime, isHD, isPrime, isAdult, audio]]
            count += addDB('episodes', episodedata)
    return count
Example #47
0
def ADD_SEASON_ITEM(seasondata,
                    mode='listtv',
                    submode='LIST_EPISODES_DB',
                    disptitle=False,
                    cmmode=0):
    asin, seriesASIN, season, seriestitle, plot, actors, network, mpaa, genres, premiered, year, stars, votes, episodetotal, audio, empty, empty, isHD, isprime, empty, poster, banner, fanart = seasondata
    infoLabels = {
        'Title': seriestitle,
        'TVShowTitle': seriestitle,
        'Plot': plot,
        'mediatype': "season",
        'MPAA': mpaa,
        'Cast': actors.split(',') if actors else None,
        'Year': year,
        'Premiered': premiered,
        'Rating': stars,
        'Votes': votes,
        'Genre': genres,
        'Episode': episodetotal,
        'Season': season,
        'Studio': network,
        'AudioChannels': audio,
        'TotalSeasons': 1
    }
    infoLabels = {k: v for k, v in infoLabels.items() if v}
    displayname = ''
    if disptitle:
        displayname = seriestitle + ' - '
    if season != 0 and len(str(season)) < 3:
        displayname += common.getString(30167, True) + ' ' + str(season)
    elif len(str(season)) > 2:
        displayname += common.getString(30168, True) + str(season)
    else:
        displayname += common.getString(30169, True)
    if showfanart:
        fanart, cover = getFanart(seriesASIN)
    infoLabels['Thumb'] = poster
    infoLabels['Fanart'] = fanart
    infoLabels['Asins'] = asin
    asin = asin.split(',')[0]
    cm = []
    cm.append((
        common.getString(30180 + cmmode) % common.getString(30167),
        'XBMC.RunPlugin(%s?mode=<common>&sitemode=<toggleWatchlist>&asin=<%s>&remove=<%s>)'
        % (sys.argv[0], asin, cmmode)))
    cm.append((common.getString(
        30183
    ), 'Container.Update(%s?mode=<appfeed>&sitemode=<getSimilarities>&asin=<%s>)'
               % (sys.argv[0], asin)))
    cm.append((
        common.getString(30155) % common.getString(30167),
        'XBMC.RunPlugin(%s?mode=<tv>&sitemode=<delfromTVdb>&asins=<%s>&table=<seasons>&title=<%s>)'
        % (sys.argv[0], urllib.quote_plus(
            infoLabels['Asins']), urllib.quote_plus(displayname))))
    common.addDir(displayname,
                  mode,
                  submode,
                  infoLabels['Asins'],
                  poster,
                  fanart,
                  infoLabels,
                  cm=cm)
Example #48
0
def ASIN_ADD(title):
    titelnum = 0
    isAdult = False
    stars = None
    votes = None
    trailer = False
    fanart = None
    poster = None
    asin, isHD, isPrime, audio = common.GET_ASINS(title)
    movietitle = title['title']
    if title.has_key('synopsis'):
        plot = title['synopsis']
    else:
        plot = None
    if title.has_key('director'):
        director = title['director']
    else:
        director = None
    if title.has_key('runtime'):
        runtime = str(title['runtime']['valueMillis']/60000)
    else:
        runtime = None
    if title.has_key('releaseOrFirstAiringDate'):
        premiered = title['releaseOrFirstAiringDate']['valueFormatted'].split('T')[0]
        year = int(premiered.split('-')[0])
    else:
        premiered = None
        year = None
    if title.has_key('studioOrNetwork'):
        studio = title['studioOrNetwork']
    else:
        studio = None
    if title.has_key('regulatoryRating'):
        if title['regulatoryRating'] == 'not_checked': mpaa = common.getString(30171)
        else: mpaa = common.getString(30170) + title['regulatoryRating']
    else:
        mpaa = ''
    if title.has_key('starringCast'):
        actors = title['starringCast']
    else:
        actors = None
    if title.has_key('genres'):
        genres = ' / '.join(title['genres']).replace('_', ' & ').replace('Musikfilm & Tanz', 'Musikfilm, Tanz')
    else:
        genres = ''
    if title.has_key('trailerAvailable'): trailer = title['trailerAvailable']
    if title.has_key('customerReviewCollection'):
        stars = float(title['customerReviewCollection']['customerReviewSummary']['averageOverallRating'])*2
        votes = str(title['customerReviewCollection']['customerReviewSummary']['totalReviewCount'])
    elif title.has_key('amazonRating'):
        if title['amazonRating'].has_key('rating'): stars = float(title['amazonRating']['rating'])*2
        if title['amazonRating'].has_key('count'): votes = str(title['amazonRating']['count'])
    if title.has_key('restrictions'):
        for rest in title['restrictions']:
            if rest['action'] == 'playback':
                if rest['type'] == 'ageVerificationRequired': isAdult = True
    if title['formats'][0].has_key('images'):
        try:
            thumbnailUrl = title['formats'][0]['images'][0]['uri']
            thumbnailFilename = thumbnailUrl.split('/')[-1]
            thumbnailBase = thumbnailUrl.replace(thumbnailFilename,'')
            poster = thumbnailBase+thumbnailFilename.split('.')[0]+'.jpg'
        except: poster = None
    if title.has_key('heroUrl'):
        fanart = title['heroUrl']
    if not 'bbl test' in movietitle.lower() and not 'test movie' in movietitle.lower():
        moviedata = [common.cleanData(x) for x in [asin,None,common.checkCase(movietitle),trailer,poster,plot,director,None,runtime,year,premiered,studio,mpaa,actors,genres,stars,votes,fanart,isPrime,isHD,isAdult,None,None,audio]]
        titelnum += addMoviedb(moviedata)
    return titelnum
Example #49
0
def ASIN_ADD(title):
    isAdult = False
    stars = None
    votes = None
    poster = None
    runtime = None
    premiered = None
    year = None
    mpaa = ''
    genres = ''
    asin, isHD, isPrime, audio = common.GET_ASINS(title)
    movietitle = title['title']
    plot = title.get('synopsis')
    fanart = title.get('heroUrl')
    director = title.get('director')
    if 'runtime' in title:
        runtime = str(title['runtime']['valueMillis'] / 60000)
    if 'releaseOrFirstAiringDate' in title:
        premiered = title['releaseOrFirstAiringDate']['valueFormatted'].split(
            'T')[0]
        year = int(premiered.split('-')[0])
    studio = title.get('studioOrNetwork')
    if 'regulatoryRating' in title:
        if title['regulatoryRating'] == 'not_checked':
            mpaa = common.getString(30171)
        else:
            mpaa = common.getString(30170) + title['regulatoryRating']
    actors = title.get('starringCast')
    if 'genres' in title:
        genres = ' / '.join(title['genres']).replace('_', ' & ').replace(
            'Musikfilm & Tanz', 'Musikfilm, Tanz')
    trailer = title.get('trailerAvailable')
    if 'customerReviewCollection' in title:
        stars = float(title['customerReviewCollection']
                      ['customerReviewSummary']['averageOverallRating']) * 2
        votes = str(title['customerReviewCollection']['customerReviewSummary']
                    ['totalReviewCount'])
    elif 'amazonRating' in title:
        if 'rating' in title['amazonRating']:
            stars = float(title['amazonRating']['rating']) * 2
        if 'count' in title['amazonRating']:
            votes = str(title['amazonRating']['count'])
    if 'restrictions' in title:
        for rest in title['restrictions']:
            if rest['action'] == 'playback' and rest[
                    'type'] == 'ageVerificationRequired':
                isAdult = True
                break
    if 'images' in title['formats'][0]:
        thumbnailUrl = title['formats'][0]['images'][0]['uri']
        thumbnailFilename = thumbnailUrl.split('/')[-1]
        thumbnailBase = thumbnailUrl.replace(thumbnailFilename, '')
        poster = thumbnailBase + thumbnailFilename.split('.')[0] + '.jpg'
    titelnum = 0
    if 'bbl test' not in movietitle.lower(
    ) and 'test movie' not in movietitle.lower():
        moviedata = [
            common.cleanData(x) for x in [
                asin, None,
                common.checkCase(movietitle), trailer, poster, plot, director,
                None, runtime, year, premiered, studio, mpaa, actors, genres,
                stars, votes, fanart, isPrime, isHD, isAdult, None, None, audio
            ]
        ]
        c = MovieDB.cursor()
        num = c.execute(
            'insert or ignore into movies values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
            moviedata).rowcount
        if num:
            MovieDB.commit()
        titelnum += num
    return titelnum
Example #50
0
def addMoviesdb(full_update=True):
    try:
        if common.args.url == 'u':
            full_update = False
    except Exception:
        pass
    dialog = xbmcgui.DialogProgress()
    if full_update:
        if common.updateRunning():
            return
        dialog.create(common.getString(30120))
        dialog.update(0, common.getString(30121))
        createMoviedb()
        MOVIE_ASINS = []
        full_update = True
    else:
        MOVIE_ASINS = getMoviedbAsins(returnlist=True)

    page = 1
    goAhead = 1
    endIndex = 0
    new_mov = 0
    tot_mov = 0
    MAX = 120

    while goAhead == 1:
        json = appfeed.getList('Movie', endIndex,
                               NumberOfResults=MAX)['message']['body']
        titles = json['titles']
        if json['approximateSize'] == 0:
            MAX = MAX - 20
            if MAX < 1:
                MAX = 120
            continue
        endIndex = json['endIndex']
        if titles:
            for title in titles:
                if full_update and dialog.iscanceled():
                    goAhead = -1
                    break
                if 'titleId' in title:
                    asin = title['titleId']
                    if '_duplicate_' not in title['title']:
                        found, MOVIE_ASINS = common.compasin(MOVIE_ASINS, asin)
                        if not found:
                            new_mov += ASIN_ADD(title)
                        tot_mov += 1
                        updateMoviedb(asin, 'popularity', tot_mov)
        if endIndex == 0:
            goAhead = 0
        page += 1
        if full_update:
            dialog.update(int((tot_mov) * 100.0 / MOV_TOTAL),
                          common.getString(30122) % page,
                          common.getString(30123) % new_mov)
        if full_update and dialog.iscanceled():
            goAhead = -1
    if goAhead == 0:
        updateLibrary()
        common.addon.setSetting("MoviesTotal", str(tot_mov))
        common.Log('Movie Update: New %s Deleted %s Total %s' %
                   (new_mov, deleteremoved(MOVIE_ASINS), tot_mov))
        if full_update:
            setNewest()
            dialog.close()
            updateFanart()
        xbmc.executebuiltin("XBMC.Container.Refresh")
        MovieDB.commit()
Example #51
0
def UpdateDialog(SERIES_COUNT, SEASON_COUNT, EPISODE_COUNT, delShows, delSeasons, delEpisodes):
    line1 = ''
    line2 = ''
    line3 = ''
    if SERIES_COUNT:
        line1 += '%s %s' % (common.getString(30132) % SERIES_COUNT, common.getString(30124))
        if delShows:
            line1 += ', %s %s' % (delShows, common.getString(30125))
    if (delShows) and (not SERIES_COUNT):
        line1 += '%s %s' % (common.getString(30132) % delShows, common.getString(30125))
    if SEASON_COUNT:
        line2 += '%s %s' % (common.getString(30133) % SEASON_COUNT, common.getString(30124))
        if delSeasons:
            line2 += ', %s %s' % (delSeasons, common.getString(30125))
    if (delSeasons) and (not SEASON_COUNT):
        line2 += '%s %s' % (common.getString(30133) % delSeasons, common.getString(30125))
    if EPISODE_COUNT:
        line3 += '%s %s' % (common.getString(30134) % EPISODE_COUNT, common.getString(30124))
        if delEpisodes:
            line3 += ', %s %s' % (delEpisodes, common.getString(30125))
    if (delEpisodes) and (not EPISODE_COUNT):
        line3 += '%s %s' % (common.getString(30134) % delEpisodes, common.getString(30125))
    if line1 + line2 + line3 == '':
        line2 = common.getString(30127)
    common.Log('TV Shows Update:\n%s\n%s\n%s' % (line1, line2, line3))
Example #52
0
def addTVdb(full_update=True, libasins=False):
    prime = True
    new_libasins = False
    try:
        if common.args.url == 'u':
            full_update = False
    except Exception:
        pass
    endIndex = 0
    goAhead = 1
    SERIES_COUNT = 0
    SEASON_COUNT = 0
    EPISODE_COUNT = 0

    if full_update and not libasins:
        if common.updateRunning():
            return
        if not Dialog.yesno(common.getString(30136), common.getString(30137), common.getString(30138) % '30'):
            return
        DialogPG.create(common.getString(30130))
        DialogPG.update(0, common.getString(30131))
        createTVdb()
        ALL_SERIES_ASINS = ''
        ALL_SEASONS_ASINS = []
    else:
        cleanDB()
        ALL_SEASONS_ASINS = getTVdbAsins('seasons', list=True)
        ALL_SERIES_ASINS = getTVdbAsins('shows')

    if libasins:
        prime = False
        ALL_SEASONS_ASINS = []
        new_libasins = checkLibraryAsins(libasins)
        if not new_libasins:
            return

    while goAhead == 1:
        json = appfeed.getList('tvepisode,tvseason,tvseries&RollupToSeason=T',
                               endIndex,
                               isPrime=prime,
                               OrderBy='Title',
                               NumberOfResults=MAX,
                               AsinList=new_libasins)
        titles = json['message']['body']['titles']
        if titles:
            SERIES_ASINS = ''
            EPISODE_ASINS = []
            EPISODE_NUM = []
            for title in titles:
                if full_update and DialogPG.iscanceled():
                    goAhead = -1
                    break
                SEASONS_ASIN = title['titleId']
                endIndex += 1
                found, ALL_SEASONS_ASINS = common.compasin(ALL_SEASONS_ASINS, SEASONS_ASIN)
                if not found:
                    if ASIN_ADD([title]):
                        SEASON_COUNT += 1
                        if title['ancestorTitles']:
                            SERIES_KEY = title['ancestorTitles'][0]['titleId']
                        else:
                            SERIES_KEY = title['titleId']
                        if SERIES_KEY not in ALL_SERIES_ASINS and 'bbl test' not in title['title'].lower():
                            SERIES_COUNT += 1
                            SERIES_ASINS += SERIES_KEY + ','
                            ALL_SERIES_ASINS += SERIES_KEY + ','
                        season_size = int(title['childTitles'][0]['size'])
                        if season_size < 1:
                            season_size = MAX
                        parsed = urlparse.urlparse(title['childTitles'][0]['feedUrl'])
                        EPISODE_ASINS.append(urlparse.parse_qs(parsed.query)['SeasonASIN'])
                        EPISODE_NUM.append(season_size)
            if len(titles) < MAX:
                goAhead = 0
            if SERIES_ASINS:
                ASIN_ADD(0, asins=SERIES_ASINS)
            if full_update:
                DialogPG.update(int(EPISODE_COUNT * 100.0 / EPI_TOTAL), common.getString(30132) % SERIES_COUNT, common.getString(30133) % SEASON_COUNT, common.getString(30134) % EPISODE_COUNT)
            episodes = 0
            AsinList = ''
            EPISODE_NUM.append(MAX + 1)
            for index, item in enumerate(EPISODE_ASINS):
                episodes += EPISODE_NUM[index]
                AsinList += ','.join(item) + ','
                if (episodes + EPISODE_NUM[index + 1]) > MAX:
                    json = appfeed.getList('TVEpisode',
                                           0,
                                           isPrime=prime,
                                           NumberOfResults=MAX,
                                           AsinList=AsinList)
                    titles = json['message']['body']['titles']
                    if titles:
                        EPISODE_COUNT += ASIN_ADD(titles)
                    if full_update and DialogPG.iscanceled():
                        goAhead = -1
                        break
                    episodes = 0
                    AsinList = ''
                    if full_update:
                        DialogPG.update(int(EPISODE_COUNT * 100.0 / EPI_TOTAL), common.getString(30132) % SERIES_COUNT, common.getString(30133) % SEASON_COUNT, common.getString(30134) % EPISODE_COUNT)
        else:
            goAhead = 0

    if goAhead == 0:
        if not libasins:
            updatePop()
            removed_seasons = []
            for item in ALL_SEASONS_ASINS:
                if item[1] == 0:
                    removed_seasons.append(item[0])
            delShows, delSeasons, delEpisodes = deleteremoved(removed_seasons)
            UpdateDialog(SERIES_COUNT, SEASON_COUNT, EPISODE_COUNT, delShows, delSeasons, delEpisodes)
            addTVdb(False, 'full')

        fixDBLShows()
        fixYears()
        fixStars()
        fixHDshows()
        updateEpisodes()
        fixTitles()
        if full_update:
            setNewest()
            DialogPG.close()
            updateFanart()
        tvDB.commit()
        common.addon.setSetting("EpisodesTotal", str(countDB('episodes')))
Example #53
0
def PLAYVIDEO():
    if not platform:
        Dialog.notification(common.__plugin__, 'Betriebssytem wird von diesem Addon nicht unterstützt', xbmcgui.NOTIFICATION_ERROR)
        return
    amazonUrl = common.BASE_URL + "/dp/" + common.args.asin
    waitsec = int(addon.getSetting("clickwait")) * 1000
    pin = addon.getSetting("pin")
    waitpin = int(addon.getSetting("waitpin")) * 1000
    waitprepin = int(addon.getSetting("waitprepin")) * 1000
    trailer = common.args.trailer
    isAdult = int(common.args.adult)
    pininput = addon.getSetting("pininput") == 'true'
    fullscr = addon.getSetting("fullscreen") == 'true'
    xbmc.Player().stop()
    
    if trailer == '1':
        videoUrl = amazonUrl + "/?autoplaytrailer=1"
    else:
        videoUrl = amazonUrl + "/?autoplay=1"

    if playMethod == 2 or platform == osAndroid:
        AndroidPlayback(common.args.asin, trailer)
        return
    else:
        if common.verbLog: videoUrl += '&playerDebug=true'
        url = getCmdLine(videoUrl, amazonUrl)
        if not url:
            Dialog.notification(common.__plugin__, common.getString(30198), xbmcgui.NOTIFICATION_ERROR)
            addon.openSettings()
            return
        common.Log('Executing: %s' % url)
        if platform == 1:
            process = subprocess.Popen(url, startupinfo=getStartupInfo())
        else:
            process = subprocess.Popen(url, shell=True)
        
    if isAdult == 1 and pininput:
        if fullscr: waitsec = waitsec*0.75
        else: waitsec = waitprepin
        xbmc.sleep(int(waitsec))
        Input(keys=pin)
        waitsec = 0
        if fullscr: xbmc.sleep(waitpin)
    
    if fullscr:
        xbmc.sleep(int(waitsec))
        if isAdult == 0: pininput = True
        if pininput:
            if browser != 0:
                Input(keys='f')
            else:
                Input(mousex=-1,mousey=350,click=2)
                xbmc.sleep(500)
                Input(mousex=9999,mousey=350)
            
    Input(mousex=9999,mousey=-1)
    
    if hasExtRC and not useIntRC: return

    myWindow = window()
    myWindow.wait(process)
Example #54
0
        try:
            tree = ET.parse(inputfile)
        except Exception, err:
            raise common.ParsingFailed("Could not parse XML file '%s': %s" %
                                       (inputfile, err))
        root = tree.getroot()
        if root.tag != 'generator':
            raise common.ParsingFailed(
                "Input file '%s' doesn't start with a generator tag" %
                inputfile)
        #
        # Get size
        self.width = common.getInt(root, 'width')
        self.height = common.getInt(root, 'height')
        #
        world_class_name = common.getString(root, 'worldClass')
        world_class = getattr(world, world_class_name)
        self.world = world_class(self.width, self.height)
        #
        return root

    def getSortedBuilders(self):
        """Return a list of the builders in the order they are defined"""
        sorted_builders = self.builders.values()
        sorted_builders.sort(lambda a, b: cmp(a.order, b.order))
        return sorted_builders

    def getSortedRenderers(self):
        """Return a list of the renderers in the order they are defined"""
        sorted_renderers = self.renderers.values()
        sorted_renderers.sort(lambda a, b: cmp(a.order, b.order))
Example #55
0
#!/usr/bin/env python

from struct import unpack
import sys
from common import getString

if len(sys.argv) != 2:
    sys.stderr.write("Usage: %s scene.ral\n" % sys.argv[0])
    exit(1)

fin = open(sys.argv[1], 'rb')
while True:
    sectionCount, strOffset, sectionOffset = unpack('>III', fin.read(12))
    if sectionCount == 0: break
    sectionSize = sectionCount * 68
    name = getString(strOffset, fin)
    print(u"%s @ 0x%X+0x%X" % (name, sectionOffset, sectionSize))
fin.close()
Example #56
0
 def readHeader(self, fin):
     self.keyframeCount, strOffset, self.sectionOffset = unpack(
         '>III', fin.read(12))
     if self.keyframeCount == 0:
         return
     self.name = getString(strOffset, fin)
Example #57
0
def ADD_MOVIE_ITEM(moviedata, onlyinfo=False, cmmode=0, export=False):
    asin, hd_asin, movietitle, trailer, poster, plot, director, writer, runtime, year, premiered, studio, mpaa, actors, genres, stars, votes, fanart, isprime, isHD, isAdult, popularity, recent, audio = moviedata
    infoLabels = {'Title': movietitle}
    if plot:
        infoLabels['Plot'] = plot
    if actors:
        infoLabels['Cast'] = actors.split(',')
    if director:
        infoLabels['Director'] = director
    if year:
        infoLabels['Year'] = year
    if premiered:
        infoLabels['Premiered'] = premiered
    if stars:
        infoLabels['Rating'] = stars
    if votes:
        infoLabels['Votes'] = votes
    if genres:
        infoLabels['Genre'] = genres
    if mpaa:
        infoLabels['mpaa'] = mpaa
    if studio:
        infoLabels['Studio'] = studio
    if runtime:
        infoLabels['Duration'] = int(runtime) * 60
    if audio:
        infoLabels['AudioChannels'] = audio
    if poster:
        infoLabels['Thumb'] = poster
    if fanart:
        infoLabels['Fanart'] = fanart
    infoLabels['isHD'] = isHD
    infoLabels['isAdult'] = isAdult
    asin = asin.split(',')[0]
    if export:
        xbmclibrary.EXPORT_MOVIE(asin)
        return
    cm = []
    cm.append((
        common.getString(30180 + cmmode) % common.getString(30154),
        'XBMC.RunPlugin(%s?mode=<common>&sitemode=<toogleWatchlist>&asin=<%s>&remove=<%s>)'
        % (sys.argv[0], asin, cmmode)))
    cm.append((
        common.getString(30185) % common.getString(30154),
        'XBMC.RunPlugin(%s?mode=<xbmclibrary>&sitemode=<EXPORT_MOVIE>&asin=<%s>)'
        % (sys.argv[0], asin)))
    cm.append((common.getString(
        30183
    ), 'Container.Update(%s?mode=<appfeed>&sitemode=<getSimilarities>&asin=<%s>)'
               % (sys.argv[0], asin)))
    cm.append(
        (common.getString(30186),
         'XBMC.RunPlugin(%s?mode=<xbmclibrary>&sitemode=<UpdateLibrary>)' %
         sys.argv[0]))
    if onlyinfo:
        return infoLabels
    else:
        common.addVideo(movietitle,
                        asin,
                        poster,
                        fanart,
                        infoLabels=infoLabels,
                        cm=cm,
                        trailer=trailer,
                        isAdult=isAdult,
                        isHD=isHD)