def computeAirdate(self, airdate, airtime): """ Computes a datetime from airdate applying offset string """ notzAirdate = datetime.datetime.strptime( airdate.strftime("%Y-%m-%d ") + airtime, "%Y-%m-%d %H:%M") jstAirdate = timezone('Asia/Tokyo').localize(notzAirdate) localAirdate = jstAirdate.astimezone( timezone(settings.getSettings().get('Anorak', 'timezone'))) return localAirdate.replace(tzinfo=None)
def processEpisode(dirName, nzbName=None): print dirName success = False for root, dirs, files in os.walk(dirName): for file in files: if(processFileAgainstDatabase(dirName, file)): success = True if (success): shutil.rmtree(dirName) if (settings.getSettings().get("Plex", "enabled")): notify.update_plex() return success
def run(self): while (True): try: print "Anorak searcher thread has woken up\n" animes = list(model.get_animes()) for anime in animes: self.searchAnime(anime) # refresh anime metadata only once a day at a random hour (so we don't DDOS anidb) if self.date < datetime.datetime.now(): refresher = MetadataRefreshThread(animes) refresher.start() self.setMetadataRefreshDate() print "Anorak searcher thread resuming sleep\n" # reload settings just in case the search frequency changed self.settings = settings.getSettings() time.sleep(60*float(self.settings.get("Anorak", "searchFrequency"))) except: print "Something went wrong with the searching thread. Continuing anyways."
def run(self): while (True): try: print "Anorak searcher thread has woken up\n" animes = list(model.get_animes()) for anime in animes: self.searchAnime(anime) # refresh anime metadata only once a day at a random hour (so we don't DDOS anidb) if self.date < datetime.datetime.now(): refresher = MetadataRefreshThread(animes) refresher.start() self.setMetadataRefreshDate() print "Anorak searcher thread resuming sleep\n" # reload settings just in case the search frequency changed self.settings = settings.getSettings() time.sleep( 60 * float(self.settings.get("Anorak", "searchFrequency"))) except: print "Something went wrong with the searching thread. Continuing anyways."
def update_plex(): _settings = settings.getSettings() host = _settings.get("Plex", "url") if host == None: print("No Plex Server host specified, check your settings") return False if not str(host)[:4] == "http": host = 'http://' + host if not str(host)[-1:] == "/": host = host + '/' print("Updating library for the Plex Media Server host: " + host) url = "%slibrary/sections" % host try: xml_sections = minidom.parse(urllib.urlopen(url)) except IOError, e: print("Error while trying to contact Plex Media Server: " + ex(e)) return False
def newAnime(anime, subber, location, airTime, quality): lang = settings.getSettings().get("Anorak", "titleLang") if lang == None: lang = "en" officialTitle = anime.titles['x-jat'][0].title try: for title in anime.titles[lang]: if title.type == "official": officialTitle = title.title except: pass model.new_anime(anime.id, anime.titles['x-jat'][0].title, subber, location, officialTitle, airTime, quality) for i in xrange(anime.episodecount): if anime.episodes.has_key(str(i + 1)): # Prevent None type from being compared with a date if anime.episodes[str(i + 1)].airdate != None: if (anime.episodes[str(i + 1)].airdate > datetime.datetime.now()): # Mark as wanted as it hasn't aired yet model.new_episode( anime.id, i + 1, anime.episodes[str(i + 1)].titles['en'][0].title, 1, anime.episodes[str(i + 1)].airdate) else: # Mark as skipped because it's already aired and we're adding. Assume we've seen this episode. model.new_episode( anime.id, i + 1, anime.episodes[str(i + 1)].titles['en'][0].title, 0, anime.episodes[str(i + 1)].airdate) else: # It doesn't have an airdate but that's probably because it doesn't have one yet. Mark as wanted. model.new_episode( anime.id, i + 1, anime.episodes[str(i + 1)].titles['en'][0].title, 1, anime.episodes[str(i + 1)].airdate) else: # This episode is so far in the future it doesn't even have any information! It must be unaired. # Mark as wanted. We'll definitely want to refresh the metadata at a later date for this one! model.new_episode(anime.id, i + 1, "Episode " + str(i + 1), 1)
def __init__(self): threading.Thread.__init__(self) self.downloader = Downloader() self.settings = settings.getSettings() self.setMetadataRefreshDate()
def computeAirdate(self, airdate, airtime): """ Computes a datetime from airdate applying offset string """ notzAirdate = datetime.datetime.strptime(airdate.strftime("%Y-%m-%d ") + airtime, "%Y-%m-%d %H:%M") jstAirdate = timezone('Asia/Tokyo').localize(notzAirdate) localAirdate = jstAirdate.astimezone(timezone(settings.getSettings().get('Anorak', 'timezone'))) return localAirdate.replace(tzinfo=None)