Normalde çalışıyor CPanel ile Python scriptini çalıştırdığım zaman sadece flask çalışıyor. Arkaplanda diğer fetch işlemini yapmıyor.
def fetch():
with open('fetch.json', encoding="utf-8") as f:
j = json.load(f)
for lang, play_lists in j.items():
play_list_json = {}
for play_list in play_lists:
url = play_list['url']
name = play_list['name']
try:
p = Playlist(url)
pmap = {}
for v in p.videos:
pmap[v.watch_url.split("watch?v=")[-1]] = v.title
print(v.title)
play_list_json[name] = pmap
except:
with open('log.txt', 'a', encoding='utf-8') as log:
log.write(f"\n[HATA : PLAYLIST] = ({url})")
if len(play_list_json) > 0:
with open(f'top/{lang}.json', 'w', encoding='utf-8') as w:
json.dump(play_list_json, w, indent=6, ensure_ascii=False)
with open('log.txt', 'a', encoding='utf-8') as log:
t = datetime.now().strftime("%d/%m/%Y, %H:%M:%S")
log.write(
f'\n{t} : {lang.upper()} dili için {len(play_list_json)} Adet Oynatma Listesi Güncellendi')
scheduler = BackgroundScheduler(job_defaults={'misfire_grace_time': 20 * 60})
scheduler.add_job(fetch, 'interval', hours=12)
if __name__ == '__main__':
scheduler.start()
app.run()