def New_AniDB(): if constants.AniDBLogging: try: netLock.acquire() global AniDBArray AniDBArray = [] file = functions.LoadFile(constants.AniDBFile, "") if file: functions.SaveFile(file + "<br />\r\n", constants.AniDBFile) finally: netLock.release()
def ExportMap(map, filename): data = copy.deepcopy(map) for item in data.xpath("""./Season/Episode/Filename"""): item.getparent().remove(item) for item in data.xpath("""./Season/Episode/Streams"""): item.getparent().remove(item) functions.SaveFile( etree.tostring(data, pretty_print=True, xml_declaration=True, encoding="UTF-8"), filename, "Bundles", constants.ExportBundles)
def New_Milestones(): if constants.MilestoneLogging: try: netLock.acquire() global LoggingArray LoggingArray = [] file = functions.LoadFile(constants.MilestoneFile, "") if file: functions.SaveFile(file + "<br />\r\n", constants.MilestoneFile) finally: netLock.release()
def update(self, metadata, media, lang, force=False): Log.Debug( "--- Update Begin -------------------------------------------------------------------------------------------" ) if force: HTTP.ClearCache() logging.New_Milestones() logging.New_AniDB() logging.Log_Milestone("WholeUpdate") common.RefreshData() source, id = metadata.id.split("-") Log("Source: %s, ID: %s" % (source, id)) #filename = "" #for sea_item in media.seasons: # Log("FileName1: %s" % (sea_item)) # for eps_item in media.seasons[sea_item].episodes: # Log("FileName2: %s" % (eps_item)) # for media_item in media.seasons[sea_item].episodes[eps_item].items: # for item_part in media_item.parts: # filename = item_part.file.lower() # Log("FileName: %s" % (filename)) #functions.downloadfile("test.webm", "https://my.mixtape.moe/sovrtq.webm") mappingData = None if source in ["anidb", "anidb2"]: mappingData = scudlee.ScudLee(id) if source in ["tvdb", "tvdb2", "tvdb3", "tvdb4", "tvdb5"]: mappingData = scudlee.ScudLee(None, id) Log.Debug( "Init - Update() - source: '%s', anidbid: '%s', tvdbid: '%s'" % (source, mappingData.AnidbId, mappingData.TvdbId)) if mappingData != None: map = common.MapSeries(mappingData) #functions.SaveFile(etree.tostring(map, pretty_print=True, xml_declaration=True, encoding="UTF-8"), mappingData.FirstSeries + ".bundle.xml", "Bundles") #common.MapLocal(media, map, mappingData.AnidbId) common.MapLocal(map, media) common.MapMeta(map) functions.SaveFile( etree.tostring(map, pretty_print=True, xml_declaration=True, encoding="UTF-8"), mappingData.FirstSeries + ".bundle.xml", "Bundles") if constants.ExportBundles: common.ExportMap(map, mappingData.FirstSeries + ".bundle.xml") common.MapMedia(map, metadata, mappingData.AnidbId, mappingData.TvdbId) logging.Log_Milestone("WholeUpdate") logging.Log_AniDB(None, True)
def Log_AniDB(id, save=False): if constants.AniDBLogging: try: netLock.acquire() global AniDBArray msg = "" if save: for entry in AniDBArray: file = functions.LoadFile(constants.AniDBFile, "") if not file: file = "" msg = ("%s | %s") % (entry, AniDBArray.count(entry)) functions.SaveFile(file + msg + "<br />\r\n", constants.AniDBFile) AniDBArray.remove(entry) else: AniDBArray.append(id) finally: netLock.release()
def Log_Milestone(milestone): if constants.MilestoneLogging: try: now = datetime.datetime.now() netLock.acquire() global LoggingArray msg = "" for entry in LoggingArray: if entry[0] == milestone: file = functions.LoadFile(constants.MilestoneFile, "") if not file: file = "" delta = now - entry[1] msg = ("%s | '%s' - '%s' : %ss : %sms : %sus") % ( entry[0], entry[1], now, delta.seconds, (delta.microseconds / 1000), delta.microseconds) functions.SaveFile(file + msg + "<br />\r\n", constants.MilestoneFile) LoggingArray.remove(entry) if len(msg) == 0: LoggingArray.append([milestone, datetime.datetime.now()]) finally: netLock.release()