def log_in_saved(self):
     username = helper.get_setting('username')
     password = helper.get_setting('password')
     helper.show_busy_notification()
     logged_in = self._login(username, password)
     msg = '%s into %s' % (('Successfully logged'
                            if logged_in else 'Failed to log'), username)
     helper.close_busy_notification()
     helper.show_small_popup(msg=msg)
Пример #2
0
    def log_in_or_out(self):
        if self.is_logged_in():
            proceed = helper.show_yes_no_dialog(
                'Are you sure you want to log out of your account?')
            if proceed:
                username = helper.get_setting('username')
                self._logout()
                helper.show_small_popup(msg=('Successfully logged out of %s' %
                                             username))
        else:
            username = helper.get_user_input('Please enter your username')
            if username == None:
                return

            password = helper.get_user_input('Please enter your password',
                                             hidden=True)
            if password == None:
                return

            helper.show_busy_notification()
            logged_in = self._login(username, password)
            msg = '%s into %s' % (('Successfully logged' if logged_in else
                                   'Failed to log'), username)
            helper.close_busy_notification()
            helper.show_small_popup(msg=msg)
Пример #3
0
    def get_metadata(self, name):
        if helper.get_setting('enable-metadata') == 'false':
            return {}

        # If we have no previous metadata, and this isn't a mismatch, then
        # we've already had a legitimate try with no luck.
        if not self.mismatch and (args.imdb_id == None
                                  and args.tmdb_id == None):
            helper.log_debug(
                'Not a mismatch and no previous results for movie')
            return {}

        imdb_id = args.imdb_id if args.imdb_id and not self.mismatch else ''
        tmdb_id = args.tmdb_id if args.tmdb_id and not self.mismatch else ''
        should_update = self.mismatch
        metadata = self.meta.get_meta('movie',
                                      name,
                                      imdb_id,
                                      tmdb_id,
                                      update=should_update)

        # Update the tvshow cache to nothing for this name
        if self.mismatch:
            self.meta.update_meta_to_nothing('tvshow', name)
            helper.log_debug('Movie mismatch - new meta: %s' % str(self.meta))

        return metadata
Пример #4
0
def __init():
    user_tmdb_key = helper.get_setting('tmdb-api-key')
    meta = None
    if user_tmdb_key != '':
        meta = AnimeMetaData(tmdb_api_key=user_tmdb_key)
    else:
        meta = AnimeMetaData()
    return meta
    def get_metadata(self, name):
        if (helper.get_setting('enable-metadata') == 'false' or 
            (args.imdb_id == None and args.tvdb_id == None)):
            return []
        
        all_metadata = self.meta.get_episodes_meta(name, args.imdb_id, args.tvdb_id, self.num_episodes,
                                                   self.first_air_date, self.season)

        return all_metadata
Пример #6
0
    def is_logged_in(self):
        username = helper.get_setting('username')
        if len(username) == 0:
            return False

        username_and_password = 0
        for cookie in self.net._cj:
            if cookie.name.lower() == 'usernamek' or cookie.name.lower(
            ) == 'passwordk':
                username_and_password += 1

        return (username_and_password == 2)
    def _get_art_for_season0(self):
        helper.start('_get_art_for_season0 for name %s and imdb_id %s' % (args.base_title, args.imdb_id))
        if helper.get_setting('enable-metadata') == 'false':
            return None, ''

        season_covers = self.meta.get_seasons(args.base_title, args.imdb_id, ['0'])
        if len(season_covers) > 0:
            icon = season_covers[0]['cover_url']
            fanart = season_covers[0]['backdrop_url']
        else:
            icon = args.icon
            fanart = args.fanart
        return icon, fanart
Пример #8
0
    def add_items(self):
        preset_quality = int(helper.get_setting('preset-quality').strip('p'))

        for option in self.links:
            quality = option.string
            if quality == 'Openload' or preset_quality >= int(
                    quality.replace('Default quality - ', '').strip('p')):
                helper.log_debug(
                    'Found media to play at matching quality: %s' % quality)
                url_to_play = option['value']
                break

        if url_to_play == None:
            helper.log_debug(
                'No matching quality found; using the lowest available')
            url_to_play = self.links[-1]['value']

        self.link = self._decode_link(url_to_play)
Пример #9
0
    def __get_best_link_for_preset_quality(self, links):
        preset_quality = int(helper.get_setting('preset-quality').strip('p'))

        for link in links:
            quality = link[0]
            if quality == 'Openload' or preset_quality >= int(
                    quality.replace('Default quality - ', '').strip('p')):
                helper.log_debug(
                    'Found media to play at matching quality: %s' % quality)
                url_to_play = link[1]
                break

        if url_to_play == None:
            helper.log_debug(
                'No matching quality found; using the lowest available')
            url_to_play = links[-1]['value']

        return url_to_play
    def get_metadata(self, name):
        helper.start('MediaContainerList.get_metadata - name: %s' % name)
        if helper.get_setting('enable-metadata'
                              ) == 'false' or name == 'Next' or name == 'Last':
            return {}, ''

        name_for_movie_search = self.clean_name(name)
        name_for_tv_search = self.clean_tv_show_name(name_for_movie_search)
        media_type = 'tvshow'

        # Not sure if movie or tv show; try tv show first
        metadata = self.meta.get_meta('tvshow',
                                      name_for_tv_search)  #, year=year)
        helper.log_debug('Got metadata %s for show %s' %
                         (metadata, name_for_tv_search))
        # It may be a movie, so let's try that with the general cleaned name
        if metadata['tvdb_id'] == '':
            metadata = self.meta.get_meta('movie',
                                          name_for_movie_search)  #, year=year)
            # If movie failed, and if there was a year in the name, try tv without it
            if metadata['tmdb_id'] == '' and re.search(
                    '( \([12][0-9]{3}\))$', name_for_tv_search) != None:
                metadata = self.meta.get_meta('tvshow',
                                              name_for_tv_search[:-7],
                                              update=True)
                if metadata['imdb_id'] != '':
                    metadata = self.meta.update_meta(
                        'tvshow',
                        name_for_tv_search,
                        imdb_id='',
                        new_imdb_id=metadata['imdb_id'])
            elif metadata['tmdb_id'] != '':  # otherwise we found a movie
                media_type = 'movie'

        helper.end('MediaContainerList.get_metadata')
        return (metadata, media_type)
    def __init__(self,
                 prepack_images=False,
                 preparezip=False,
                 tmdb_api_key='af95ef8a4fe1e697f86b8c194f2e5e11'):
        '''
        A copy of __init__ from the metahandler plugin, modified to use a 
        different db path, which unfortunately required pasting this function 
        and modifying it :/
        '''
        # TMDB constants
        self.tmdb_image_url = ''
        self.path = helper.get_profile()
        self.cache_path = make_dir(self.path, 'meta_cache')
        user_tmdb_key = helper.get_setting('tmdb-api-key')
        self.tmdb_api_key = user_tmdb_key if user_tmdb_key != '' else tmdb_api_key

        if prepack_images:
            #create container working directory
            #!!!!!Must be matched to workdir in metacontainers.py create_container()
            self.work_path = make_dir(self.path, 'work')

        #set movie/tvshow constants
        self.type_movie = 'movie'
        self.type_tvshow = 'tvshow'
        self.type_season = 'season'
        self.type_episode = 'episode'

        #this init auto-constructs necessary folder hierarchies.

        # control whether class is being used to prepare pre-packaged .zip
        self.prepack_images = bool2string(prepack_images)
        self.videocache = os.path.join(self.cache_path, 'video_cache.db')
        self.tvpath = make_dir(self.cache_path, self.type_tvshow)
        self.tvcovers = make_dir(self.tvpath, 'covers')
        self.tvbackdrops = make_dir(self.tvpath, 'backdrops')
        self.tvbanners = make_dir(self.tvpath, 'banners')
        self.mvpath = make_dir(self.cache_path, self.type_movie)
        self.mvcovers = make_dir(self.mvpath, 'covers')
        self.mvbackdrops = make_dir(self.mvpath, 'backdrops')

        # connect to db at class init and use it globally
        if DB == 'mysql':

            class MySQLCursorDict(database.cursor.MySQLCursor):
                def _row_to_python(self, rowdata, desc=None):
                    row = super(MySQLCursorDict,
                                self)._row_to_python(rowdata, desc)
                    if row:
                        return dict(zip(self.column_names, row))
                    return None

            db_address = common.addon.get_setting('db_address')
            db_port = common.addon.get_setting('db_port')
            if db_port: db_address = '%s:%s' % (db_address, db_port)
            db_user = common.addon.get_setting('db_user')
            db_pass = common.addon.get_setting('db_pass')
            db_name = common.addon.get_setting('db_name')
            self.dbcon = database.connect(database=db_name,
                                          user=db_user,
                                          password=db_pass,
                                          host=db_address,
                                          buffered=True)
            self.dbcur = self.dbcon.cursor(cursor_class=MySQLCursorDict,
                                           buffered=True)
        else:
            self.dbcon = database.connect(self.videocache,
                                          isolation_level=None,
                                          check_same_thread=False)
            self.dbcon.row_factory = database.Row  # return results indexed by field names and not numbers so we can convert to dict
            self.dbcur = self.dbcon.cursor()

        # initialize cache db
        self._cache_create_movie_db()

        # Check TMDB configuration, update if necessary
        self._set_tmdb_config()

        # Add the absolute_number column here, which is helpful for animes
        if not self._does_column_exist('absolute_episode', 'episode_meta'):
            sql_alter = "ALTER TABLE episode_meta ADD absolute_episode INTEGER"
            try:
                self.dbcur.execute(sql_alter)
                helper.log_debug(
                    'Successfully added the absolute_episode column')
            except:
                helper.log_debug('Failed to alter the table')
        else:
            helper.log_debug('The absolute_episode column already exists')

        common.addon.log = helper.log
        self.lock = threading.Lock()
Пример #12
0
 def _get_action_and_isfolder(self):
     select_quality = helper.get_setting('preset-quality') == 'Individually select'
     action = 'quality' if select_quality else 'autoplay'
     is_folder = select_quality # Display a folder if we have to select the quality
     return action, is_folder