def scanMovieDB(myMediaURL, outFile): Log.Debug("******* Starting scanMovieDB with an URL of %s ***********" % (myMediaURL)) Log.Debug('Movie Export level is %s' % (Prefs['Movie_Level'])) global bScanStatusCount global bScanStatusCountOf global bScanStatus bScanStatusCount = 0 bScanStatusCountOf = 0 iCurrent = 0 try: Log.Debug("About to open file %s" % (outFile)) output.createHeader(outFile, 'movies') if Prefs['Movie_Level'] in moviefields.singleCall: bExtraInfo = False else: bExtraInfo = True while True: Log.Debug("Walking medias") fetchURL = myMediaURL + '?X-Plex-Container-Start=' + str( iCurrent) + '&X-Plex-Container-Size=' + str( CONTAINERSIZEMOVIES) iCount = bScanStatusCount partMedias = XML.ElementFromURL(fetchURL, timeout=float(PMSTIMEOUT)) if bScanStatusCount == 0: bScanStatusCountOf = partMedias.get('totalSize') Log.Debug('Amount of items in this section is %s' % bScanStatusCountOf) # HERE WE DO STUFF Log.Debug("Retrieved part of medias okay [%s of %s]" % (str(bScanStatusCount), str(bScanStatusCountOf))) medias = partMedias.xpath('.//Video') for media in medias: myRow = {} # Was extra info needed here? if bExtraInfo: myExtendedInfoURL = genParam( misc.GetLoopBack() + '/library/metadata/' + misc.GetRegInfo(media, 'ratingKey')) media = XML.ElementFromURL( myExtendedInfoURL, timeout=float(PMSTIMEOUT)).xpath('//Video')[0] # Export the info myRow = movies.getMovieInfo(media, myRow) output.writerow(myRow) iCurrent += 1 bScanStatusCount += 1 Log.Debug("Media #%s from database: '%s'" % (str(iCurrent), misc.GetRegInfo(media, 'title'))) # Got to the end of the line? if int(partMedias.get('size')) == 0: break if bScanStatus == 3: break output.closefile() except ValueError, Argument: Log.Critical('Unknown error in scanMovieDb %s' % (Argument)) bScanStatus = 99 raise
def scanMovieDB(myMediaURL, myCSVFile): Log.Debug("******* Starting scanMovieDB with an URL of %s ***********" %(myMediaURL)) Log.Debug('Movie Export level is %s' %(Prefs['Movie_Level'])) global bScanStatusCount global bScanStatusCountOf global bScanStatus bScanStatusCount = 0 bScanStatusCountOf = 0 iCurrent = 0 try: Log.Debug("About to open file %s" %(myCSVFile)) csvfile = io.open(myCSVFile,'wb') # Create output file, and print the header csvwriter = csv.DictWriter(csvfile, fieldnames=movies.getMovieHeader(Prefs['Movie_Level']), delimiter=Prefs['Delimiter'], quoting=csv.QUOTE_NONNUMERIC) Log.Debug("Writing header") csvwriter.writeheader() if Prefs['Movie_Level'] in moviefields.singleCall: bExtraInfo = False else: bExtraInfo = True while True: Log.Debug("Walking medias") fetchURL = myMediaURL + '?X-Plex-Container-Start=' + str(iCurrent) + '&X-Plex-Container-Size=' + str(consts.CONTAINERSIZEMOVIES) iCount = bScanStatusCount partMedias = XML.ElementFromURL(fetchURL, timeout=float(consts.PMSTIMEOUT)) if bScanStatusCount == 0: bScanStatusCountOf = partMedias.get('totalSize') Log.Debug('Amount of items in this section is %s' %bScanStatusCountOf) # HERE WE DO STUFF Log.Debug("Retrieved part of medias okay [%s of %s]" %(str(bScanStatusCount), str(bScanStatusCountOf))) medias = partMedias.xpath('.//Video') for media in medias: myRow = {} # Was extra info needed here? if bExtraInfo: myExtendedInfoURL = misc.GetLoopBack() + '/library/metadata/' + misc.GetRegInfo(media, 'ratingKey') + '?includeExtras=1&includeChapters=1' if Prefs['Check_Files']: myExtendedInfoURL = myExtendedInfoURL + '&checkFiles=1&includeChapters=1' media = XML.ElementFromURL(myExtendedInfoURL, timeout=float(consts.PMSTIMEOUT)).xpath('//Video')[0] # Export the info myRow = movies.getMovieInfo(media, myRow, csvwriter) csvwriter.writerow(myRow) iCurrent += 1 bScanStatusCount += 1 Log.Debug("Media #%s from database: '%s'" %(str(iCurrent), misc.GetRegInfo(media, 'title'))) # Got to the end of the line? if int(partMedias.get('size')) == 0: break csvfile.close except ValueError, Argument: Log.Critical('Unknown error in scanMovieDb %s' %(Argument)) bScanStatus = 99 raise
def scanMovieDB(myMediaURL, myCSVFile): Log.Debug("******* Starting scanMovieDB with an URL of %s ***********" %(myMediaURL)) Log.Debug('Movie Export level is %s' %(Prefs['Movie_Level'])) global bScanStatusCount global bScanStatusCountOf global bScanStatus bScanStatusCount = 0 bScanStatusCountOf = 0 iCurrent = 0 try: Log.Debug("About to open file %s" %(myCSVFile)) csvfile = io.open(myCSVFile,'wb') # Create output file, and print the header csvwriter = csv.DictWriter(csvfile, fieldnames=movies.getMovieHeader(Prefs['Movie_Level']), delimiter=Prefs['Delimiter'], quoting=csv.QUOTE_NONNUMERIC) Log.Debug("Writing header") csvwriter.writeheader() if Prefs['Movie_Level'] in moviefields.singleCall: bExtraInfo = False else: bExtraInfo = True while True: Log.Debug("Walking medias") fetchURL = myMediaURL + '?X-Plex-Container-Start=' + str(iCurrent) + '&X-Plex-Container-Size=' + str(consts.CONTAINERSIZEMOVIES) iCount = bScanStatusCount partMedias = XML.ElementFromURL(fetchURL) if bScanStatusCount == 0: bScanStatusCountOf = partMedias.get('totalSize') Log.Debug('Amount of items in this section is %s' %bScanStatusCountOf) # HERE WE DO STUFF Log.Debug("Retrieved part of medias okay [%s of %s]" %(str(bScanStatusCount), str(bScanStatusCountOf))) medias = partMedias.xpath('.//Video') for media in medias: myRow = {} # Was extra info needed here? if bExtraInfo: myExtendedInfoURL = misc.GetLoopBack() + '/library/metadata/' + misc.GetRegInfo(media, 'ratingKey') + '?includeExtras=1' if Prefs['Check_Files']: myExtendedInfoURL = myExtendedInfoURL + '&checkFiles=1' media = XML.ElementFromURL(myExtendedInfoURL).xpath('//Video')[0] # Export the info myRow = movies.getMovieInfo(media, myRow, csvwriter) csvwriter.writerow(myRow) iCurrent += 1 bScanStatusCount += 1 Log.Debug("Media #%s from database: '%s'" %(str(iCurrent), misc.GetRegInfo(media, 'title'))) # Got to the end of the line? if int(partMedias.get('size')) == 0: break csvfile.close except ValueError, Argument: Log.Critical('Unknown error in scanMovieDb %s' %(Argument)) bScanStatus = 99 raise
def scanMovieDB(myMediaURL, myCSVFile): Log.Debug("******* Starting scanMovieDB with an URL of %s ***********" %(myMediaURL)) Log.Debug('Movie Export level is %s' %(Prefs['Movie_Level'])) global bScanStatusCount global bScanStatusCountOf global bScanStatus bScanStatusCount = 0 bScanStatusCountOf = 0 iCurrent = 0 try: Log.Debug("About to open file %s" %(myCSVFile)) csvfile = io.open(myCSVFile,'wb') # Create output file, and print the header csvwriter = csv.DictWriter(csvfile, fieldnames=movies.getMovieHeader(Prefs['Movie_Level']), delimiter=Prefs['Delimiter'], quoting=csv.QUOTE_NONNUMERIC) Log.Debug("Writing header") csvwriter.writeheader() while True: Log.Debug("Walking medias") fetchURL = myMediaURL + '?X-Plex-Container-Start=' + str(iCurrent) + '&X-Plex-Container-Size=' + str(consts.CONTAINERSIZEMOVIES) iCount = bScanStatusCount partMedias = XML.ElementFromURL(fetchURL, headers=MYHEADER) if bScanStatusCount == 0: bScanStatusCountOf = partMedias.get('totalSize') Log.Debug('Amount of items in this section is %s' %bScanStatusCountOf) # HERE WE DO STUFF Log.Debug("Retrieved part of medias okay [%s of %s]" %(str(bScanStatusCount), str(bScanStatusCountOf))) medias = partMedias.xpath('.//Video') for media in medias: myRow = {} # Export the info myRow = movies.getMovieInfo(media, myRow, MYHEADER, csvwriter) csvwriter.writerow(myRow) iCurrent += 1 bScanStatusCount += 1 Log.Debug("Media #%s from database: '%s'" %(str(iCurrent), misc.GetRegInfo(media, 'title'))) # Got to the end of the line? if int(partMedias.get('size')) == 0: break csvfile.close except ValueError, Argument: Log.Critical('Unknown error in scanMovieDb %s' %(Argument)) bScanStatus = 99 raise e