Пример #1
0
def searchForShortSeries(seriesName, language):
    params = {'seriesname':seriesName, 'language':language}
    response = httphelper.doGetRequest(mirrorUrl, mirrorPort, searchForShortSeriesPath, params)
    seriesXmlList = ElementTree.parse(response).findall(r'.//Series')
    
    searchResults = []
    for xmlSeries in seriesXmlList:
        result = xmlToShortSeries(xmlSeries)
        
        searchResults.append(result)
    
    return searchResults
Пример #2
0
def searchForLongSeries(tvdbId, language):
    path = buildFullSeriesURL(tvdbId, language)
    params = {}
    response = httphelper.doGetRequest(mirrorUrl, mirrorPort, path, params)
    
    zipFile = tempfile.NamedTemporaryFile(suffix='.zip', prefix='pytvdb', delete=True)
    zipFile.write(response.read())
    zipFile.seek(0)
    
    unZipDir = tempfile.mkdtemp()
    unZipper = unziphelper.unzip()
    unZipper.extract(zipFile, unZipDir)
    
    seriesXML = os.path.join(unZipDir, language + '.xml')
    if os.path.isfile(seriesXML):
        seriesXMLFile = open(seriesXML)
        series = XMLToLongSeries(seriesXMLFile)
        seriesXMLFile.close()
    
    actorsXML = os.path.join(unZipDir, 'actors.xml')
    if os.path.isfile(actorsXML):
        actorsXMLFile = open(actorsXML)
        series.actors = XMLToActors(actorsXMLFile)
        actorsXMLFile.close()
        
    bannersXML = os.path.join(unZipDir, 'banners.xml')
    if os.path.isfile(bannersXML):
        bannersXMLFile = open(bannersXML)
        series.banners = XMLToBanners(bannersXMLFile)
        bannersXMLFile.close()
    
    series.updatedTime = getServerTime()
    
    zipFile.close()
    shutil.rmtree(unZipDir)
    
    
    return series
Пример #3
0
def getServerTime():
    response = httphelper.doGetRequest(mirrorUrl, mirrorPort, serverTimePath, serverTimeParams)
    timeElement = ElementTree.parse(response).findall(r'.//Time')

    timeSinceEpoch = timeElement[0].text
    return timeSinceEpoch