Exemple #1
0
def downloadSeriesXML(xmlFileName, aid, version):
    logger.info("Downloading information for {1}".format(xmlFileName, aid))
    # wait to prevent ban on anidb server
    sleep(3)
    url = 'http://api.anidb.net:9001/httpapi?request=anime&client=pyanisort&'
    url += 'clientver=' + str(version)
    url += '&protover=1&aid=' + str(aid)
    utilities.downloadFile(url, xmlFileName)
Exemple #2
0
def generatePrefNameCSV(xmlFilename, ShowList):
    try:
        xmlFileObject = utilities.openFile(xmlFilename)
    except IOError as e:
        url = 'http://anidb.net/api/animetitles.xml.gz'
        utilities.downloadFile(url, xmlFilename)
        xmlFileObject = utilities.openFile(xmlFilename)
        logger.info("'{0}' not found: downloading".format(xmlFilename))

    #open xmlfile once here for faster parsing
    tree = ET.parse(xmlFileObject)
    root = tree.getroot()
    preferedNames=[]
    for show in ShowList:
        showMatches = findShowMatches(show, root)
        if (len(showMatches) == 0):
            # check date of latest animetitles.xml.gz
            # get new one if it was not already downloaded today
            if utilities.checkFileAge(xmlFilename):
                url = 'http://anidb.net/api/animetitles.xml.gz'
                utilities.downloadFile(url, xmlFilename)
                # search through xml file again
                xmlFileObject = utilities.openFile(xmlFilename)
                tree = ET.parse(xmlFileObject)
                root = tree.getroot()
                showMatches = findShowMatches(show, root)
        #get user to pick show from list or write a warning and do nothing if silent is on
        if (len(showMatches) > 1):
            if not silent:
                print('{0} matches for show {1}'.format(
                    len(showMatches), show))
                showChoice = listChoice(showMatches)
                showChoice.append(show)
                preferedNames.append(showChoice)
                showMatches = [showChoice]
                logger.debug("{0} Matched: '{1}' with {2}".format(xmlFilename, show, showChoice))
            else:
                logger.warning("Multiple matches found for title '{0}' silent mode is on".format(title))
                showMatches = []
        elif (len(showMatches) == 1):
            showMatches[0].append(show)
            preferedNames.append(showMatches[0])
            logger.debug("{0} Matched: '{1}' with {2}".format(xmlFilename, show, showMatches[0]))
        else:
            logger.error("Anime '{0}' not found".format(show))

    return preferedNames