示例#1
0
 def __init__(self,
              token,
              fullURL,
              tvdata_on_plex=None,
              didend=None,
              toGet=None,
              verify=True):
     super(TVDBGUI, self).__init__(None, isIsolated=True, doQuit=True)
     self.fullURL = fullURL
     self.token = token
     self.tvdb_token = get_token(verify=verify)
     self.verify = verify
     self.setStyleSheet("""
     QWidget {
     font-family: Consolas;
     font-size: 11;
     }""")
     self.hide()
     self.progress_dialog = ProgressDialog(self,
                                           'PLEX TV GUI PROGRESS WINDOW')
     #
     showsToExclude = plextvdb.get_shows_to_exclude(tvdata_on_plex)
     self.initThread = TVDBGUIThread(self.fullURL,
                                     self.token,
                                     self.tvdb_token,
                                     tvdata_on_plex=tvdata_on_plex,
                                     didend=didend,
                                     toGet=toGet,
                                     verify=verify,
                                     showsToExclude=showsToExclude)
     self.initThread.emitString.connect(self.progress_dialog.addText)
     self.initThread.finalData.connect(self.process_final_state)
     self.initThread.start()
示例#2
0
def get_tot_epdict_imdb(showName, verify=True):
    """
    Returns a summary nested :py:class:`dict` of episode information for a given TV show, using :py:class:`IMDb <imdb.IMDb>` class in the `IMDB Python Package`_.

    * The top level dictionary has keys that are the TV show's seasons. Each value is a second level dictionary of information about each season.

    * The second level dictionary has keys (for each season) that are the season's episodes. Each value is a :py:class:`tuple` of episode name and air date, as a :py:class:`date <datetime.date>`.

    An example of the structure of this dictionary can be found in :py:meth:`get_tot_epdict_tvdb <plextvdb.plextvdb.get_tot_epdict_tvdb>`.

    .. seealso::

       * :py:meth:`get_tot_epdict_tvdb <plextvdb.plextvdb.get_tot_epdict_tvdb>`.
       * :py:meth:`get_tot_epdict_omdb <plextvdb.plextvdb_attic.get_tot_epdict_omdb>`.
       * :py:meth:`get_tot_epdict_tmdb <plextvdb.plextvdb_attic.get_tot_epdict_tmdb>`.

    .. _`IMDB Python Package`: https://imdbpy.readthedocs.io/en/latest
    """
    token = get_token(verify=verify)
    tvdb_id = plextvdb.get_series_id(showName, token, verify=verify)
    if tvdb_id is None: return None
    imdbId = plextvdb.get_imdb_id(tvdb_id, token, verify=verify)
    if imdbId is None: return None
    #
    ## now run imdbpy
    time0 = time.time()
    ia = IMDb()
    imdbId = imdbId.replace('tt', '').strip()
    series = ia.get_movie(imdbId)
    ia.update(series, 'episodes')
    logging.debug('took %0.3f seconds to get episodes for %s.' %
                  (time.time() - time0, showName))
    tot_epdict = {}
    seasons = sorted(
        set(filter(lambda seasno: seasno != -1, series['episodes'].keys())))
    tot_epdict_tvdb = plextvdb.get_tot_epdict_tvdb(showName, verify=verify)
    for season in sorted(set(seasons) & set(tot_epdict_tvdb)):
        tot_epdict.setdefault(season, {})
        for epno in series['episodes'][season]:
            episode = series['episodes'][season][epno]
            title = episode['title'].strip()
            try:
                firstAired_s = episode['original air date']
                firstAired = datetime.datetime.strptime(
                    firstAired_s, '%d %b. %Y').date()
            except:
                firstAired = tot_epdict_tvdb[season][epno][-1]
            tot_epdict[season][epno] = (title, firstAired)
    return tot_epdict
示例#3
0
#
## start the application here
logging.basicConfig( level = logging.INFO )
parser = OptionParser( )
parser.add_option('-s', '--series', type=str, dest='series', action='store',
                  default='The Simpsons',
                  help = 'Name of the series to choose. Default is "The Simpsons".' )
opts, args = parser.parse_args( )
app = QApplication([])
app.setStyleSheet( qdarkstyle.load_stylesheet_pyqt( ) )
tvdata = pickle.load(
    gzip.open( os.path.join( testDir, 'tvdata.pkl.gz' ), 'rb' ) )
toGet = pickle.load( gzip.open(
    gzip.open( os.path.join( testDir, 'toGet.pkl.gz' ), 'rb' ) )
didend = pickle.load( gzip.open(
    os.path.join( testDir, 'didend.pkl.gz'), 'rb' ) )
assert( opts.series in tvdata )
_, plex_token = plexcore.checkServerCredentials(
    doLocal = False, verify = False )
tvdb_token = get_token( verify = False )
tvdb_show_gui = plextvdb_gui.TVDBShowGUI(
    opts.series, tvdata, toGet, tvdb_token, plex_token,
    verify = False )
tvdb_show_gui.setStyleSheet("""
QWidget {
font-family: Consolas;
font-size: 11;
}""" )
result = tvdb_show_gui.exec_( )
示例#4
0
testDir = os.path.expanduser( '~/.config/plexstuff/tests' )

#
## start the application here
logging.basicConfig( level = logging.INFO )
parser = OptionParser( )
parser.add_option('-s', '--series', type=str, dest='series', action='store', default='The Simpsons',
                  help = 'Name of the series to choose. Default is "The Simpsons".' )
parser.add_option('-S', '--season', type=int, dest='season', action='store', default=1,
                  help = 'Season number to examine. Default is 1.' )
opts, args = parser.parse_args( )
app = QApplication([])
app.setStyleSheet( qdarkstyle.load_stylesheet_pyqt( ) )
tvdata = pickle.load(
    gzip.open( os.path.join( testDir, 'tvdata.pkl.gz' ), 'rb' ) )
toGet = pickle.load(
    gzip.open( os.path.join( testDir, 'toGet.pkl.gz' ), 'rb' ) )
fullURL, plex_token = plexcore.checkServerCredentials(
    doLocal = False, verify = False )
assert( opts.season > 0 )
assert( opts.series in tvdata )
assert( opts.season in tvdata[ opts.series ][ 'seasons' ] )
missing_eps = dict(map(
    lambda seriesName: ( seriesName, toGet[ seriesName ][ 'episodes' ] ),
    toGet ) )#
tvdb_season_gui = plextvdb_season_gui.TVDBSeasonGUI(
    opts.series, opts.season, tvdata, missing_eps, get_token( False ),
    plex_token, verify = False )
result = app.exec_( )
示例#5
0
    default='The Simpsons',
    help='Name of the series to choose. Default is "The Simpsons".')
parser.add_option('-S',
                  '--season',
                  type=int,
                  dest='season',
                  action='store',
                  default=1,
                  help='Season number to examine. Default is 1.')
opts, args = parser.parse_args()
app = QApplication([])
app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt())
tvdata = pickle.load(gzip.open(os.path.join(testDir, 'tvdata.pkl.gz'), 'rb'))
toGet = pickle.load(gzip.open(os.path.join(testDir, 'toGet.pkl.gz'), 'rb'))
fullURL, plex_token = plexcore.checkServerCredentials(doLocal=False,
                                                      verify=False)
assert (opts.season > 0)
assert (opts.series in tvdata)
assert (opts.season in tvdata[opts.series]['seasons'])
missing_eps = dict(
    map(lambda seriesName: (seriesName, toGet[seriesName]['episodes']),
        toGet))  #
tvdb_season_gui = plextvdb_season_gui.TVDBSeasonGUI(opts.series,
                                                    opts.season,
                                                    tvdata,
                                                    missing_eps,
                                                    get_token(False),
                                                    plex_token,
                                                    verify=False)
result = app.exec_()