Example #1
0
def push_anidb_mylist(filepath, anidb_episode):
    # type: (AnyStr, Any) -> Tuple[Optional[bool], Optional[Tuple[AnyStr, int]]]
    """
    :param filepath: file path
    :type filepath: AnyStr
    :param anidb_episode:
    :type anidb_episode:
    :return
    """
    result, log = None, None
    if set_up_anidb_connection():
        if not anidb_episode:  # seems like we could parse the name before, build the anidb object
            # build an anidb episode
            anidb_episode = adba.Episode(
                sickbeard.ADBA_CONNECTION,
                filePath=filepath,
                paramsF=['quality', 'anidb_file_name', 'crc32'],
                paramsA=[
                    'epno', 'english_name', 'short_name_list', 'other_name',
                    'synonym_list'
                ])

        try:
            anidb_episode.add_to_mylist(
                state=1
            )  # status = 1 sets the status of the file to "internal HDD"
            log = ('Adding the file to the anidb mylist', logger.DEBUG)
            result = True
        except (BaseException, Exception) as e:
            log = (u'exception msg: %s' % ex(e), logger.MESSAGE)
            result = False

    return result, log
Example #2
0
    def loadEpisode(self, connection, metadata, season, episode, force):

        epno = episode
        if str(season) == "0":
            epno = "S" + str(ep)

        episodeKey = str(season) + "-" + str(episode) + "-"

        Log("Force: " + str(force))
        Log("Has key: " + str(str(episodeKey + "title") in Dict))

        if str(episodeKey + "title") in Dict and not force:
            Log("Metadata for '" + metadata.title + "', season " + season +
                " episode " + epno + " found in cache")
            return episodeKey

        Log("Loading metadata for '" + metadata.title + "', season " + season +
            " episode " + epno + " from AniDB")

        episode = adba.Episode(connection, aid=metadata.id, epno=episode)

        try:
            episode.load_data()
        except IndexError, e:
            Log("Episode number is incorrect, msg: " + str(e) +
                " for episode " + epno)
Example #3
0
    def _build_anidb_episode(self, connection, filePath):
        """
        Look up anidb properties for an episode

        :param connection: anidb connection handler
        :param filePath: file to check
        :return: episode object
        """
        ep = adba.Episode(connection, filePath=filePath,
                          paramsF=["quality", "anidb_file_name", "crc32"],
                          paramsA=["epno", "english_name", "short_name_list", "other_name", "synonym_list"])

        return ep
Example #4
0
def get_anime_episode(file_path):
    """
    Look up anidb properties for an episode

    :param file_path: file to check
    :return: episode object
    """
    ep = None

    if set_up_anidb_connection():
        ep = adba.Episode(sickrage.app.adba_connection,
                          filePath=file_path,
                          paramsF=["quality", "anidb_file_name", "crc32"],
                          paramsA=[
                              "epno", "english_name", "short_name_list",
                              "other_name", "synonym_list"
                          ])

    return ep
Example #5
0
        connection.auth(args.username, args.password)
    except Exception as e:
        print('Exception: %s', e)

# Execute command
if args.command == 'hash':
    # Hash the file
    for thisFile in fileList:
        thisED2K = adba.aniDBfileInfo.get_ED2K(thisFile, forceHash=True)
        print(thisED2K)
elif args.command == 'mylistadd':
    # First try to add the file, then try to edit
    if connection.authed():
        for thisFile in fileList:
            try:
                episode = adba.Episode(connection, filePath=thisFile)
            except Exception as e:
                print('Exception: %s', e)
                continue
            try:
                episode.edit_to_mylist(state=args.state,
                                       viewed=viewed,
                                       source=args.source,
                                       storage=args.storage,
                                       other=args.other)
                print(thisFile + " successfully edited in AniDB MyList.")
            except:
                try:
                    episode.add_to_mylist(state=args.state,
                                          viewed=viewed,
                                          source=args.source,
Example #6
0
    sys.exit(1)

# First find show title in AniDB, else skip file
sys.stderr.write("Identifying files in AniDB...\n")
requestedFields = list(["romaji_name"])
maper = adba.aniDBmaper.AniDBMaper()
maperFileF = set(maper.getFileMapF())
maperFileA = set(maper.getFileMapA())
requestF = list(maperFileF & set(requestedFields))
requestA = list(maperFileA & set(requestedFields))
if connection.authed():
    for i in range(1, len(sys.argv)):
        try:
            episode = adba.Episode(connection,
                                   filePath=sys.argv[i],
                                   load=True,
                                   paramsF=requestF,
                                   paramsA=requestA)
        except:
            sys.stderr.write("ERROR: " + sys.argv[i] + " not in AniDB!\n")
            continue
        # pprint.pprint(vars(episode))
        # Sanitize name for a folder name
        title = sanitizeFilename(str(getattr(episode, "romaji_name")))
        # Add to tuple list of file with target folder
        sys.stderr.write("Title identified as " + title + "\n")
        filesWithTitles.append((sys.argv[i], title))
else:
    sys.stderr.write(
        "Cannot authorize connection to AniDB! Press enter to exit...\n")
    input()
Example #7
0
File: test.py Project: labrys/adba
except Exception as e:
    print(("exception msg: " + str(e)))

group = connection.group(gname="Doki Fansubs")
for line in group.datalines:
    print(line["shortname"])

# we create an Episode with:
# file: path the file we would like to identify
# paramsF: info we want from the file. for a full list look at adba.maper.aniDBMaper.AniDBMaper.getFileMapF
# paramsA: info we want from the anime. for a full list look at adba.maper.aniDBMaper.AniDBMaper.getFileMapA
# for all params: the order is irrelevant
episode = adba.Episode(connection,
                       filePath=filePath,
                       paramsF=["quality", "anidb_file_name", "crc32", "gid"],
                       paramsA=[
                           "epno", "english_name", "other_name",
                           "short_name_list", "synonym_list"
                       ])

if connection.authed():
    # we now got an object that holds the info we have and the info we want
    # lets try get the data from the server
    # try:
    print(("Trying to lookup " + str(filePath) + " on anidb"))
    # simply call load_data()
    episode.load_data()
    # except Exception as e :
    # print(("exception msg: "+str(e)))

# lets see if we got some valid info