Added logging
This commit is contained in:
parent
f32f0e7d1e
commit
e2321915e0
7
main.py
7
main.py
|
@ -5,6 +5,10 @@ import yt_dlp as youtube_dl
|
||||||
from config import DISCORD_BOT_TOKEN, DISCORD_CHANNEL_ID, YOUTUBE_CHANNEL_IDS
|
from config import DISCORD_BOT_TOKEN, DISCORD_CHANNEL_ID, YOUTUBE_CHANNEL_IDS
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
intents = discord.Intents.default()
|
intents = discord.Intents.default()
|
||||||
intents.messages = True
|
intents.messages = True
|
||||||
intents.guilds = True
|
intents.guilds = True
|
||||||
|
@ -20,6 +24,7 @@ ydl_opts = {
|
||||||
}
|
}
|
||||||
|
|
||||||
downloaded_videos_file = 'downloaded_videos.txt'
|
downloaded_videos_file = 'downloaded_videos.txt'
|
||||||
|
|
||||||
def get_downloaded_videos():
|
def get_downloaded_videos():
|
||||||
if not os.path.exists(downloaded_videos_file):
|
if not os.path.exists(downloaded_videos_file):
|
||||||
return set()
|
return set()
|
||||||
|
@ -38,8 +43,10 @@ def get_latest_video_url(channel_id):
|
||||||
|
|
||||||
@tasks.loop(minutes=10)
|
@tasks.loop(minutes=10)
|
||||||
async def check_new_videos():
|
async def check_new_videos():
|
||||||
|
logging.info("Checking new videos...")
|
||||||
downloaded_videos = get_downloaded_videos()
|
downloaded_videos = get_downloaded_videos()
|
||||||
for channel_id in YOUTUBE_CHANNEL_IDS:
|
for channel_id in YOUTUBE_CHANNEL_IDS:
|
||||||
|
logging.info(f"Checking channel: {channel_id}")
|
||||||
video_url, video_id = get_latest_video_url(channel_id)
|
video_url, video_id = get_latest_video_url(channel_id)
|
||||||
if video_url and video_id not in downloaded_videos:
|
if video_url and video_id not in downloaded_videos:
|
||||||
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
||||||
|
|
Loading…
Reference in New Issue