diff --git a/archiver.py b/archiver.py index 5e8fb1e..43992e8 100644 --- a/archiver.py +++ b/archiver.py @@ -9,11 +9,10 @@ from compression.compressor import main as compressor_main from convert.local import convert_videos from config import API_KEY, YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION, DOWNLOAD_QUALITY, SKIP_SHORTS -from utils.misc.misc import check_config, info_getter, print_status -from utils.ytutils.ythelper import parse_duration, is_short -from utils.dlutils.dl import download_video +from utils.misc.misc import check_config, info_getter +from utils.ytutils.ythelper import get_channel_id, get_video_ids, get_video_details, parse_duration, is_short +from utils.dlutils.dl import download_video, print_status from utils.dlutils.path import save_download_path -from utils.ytutils.get import get_channel_id, get_video_ids, get_video_details check_config() @@ -28,7 +27,7 @@ def main(): os.system('cls' if os.name == 'nt' else 'clear') info_getter() channel_name = input("\nEnter YouTube channel name: ") - channel_id, display_name = get_channel_id(channel_name) + channel_id = get_channel_id(channel_name) base_path = os.path.join('yt_data', channel_id) os.makedirs(base_path, exist_ok=True) @@ -74,7 +73,7 @@ def main(): timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") with open(channel_info_path, 'w', encoding='utf-8') as channel_info_file: - channel_info_file.write(f"Channel Name: {display_name}\n") + channel_info_file.write(f"Channel Name: {channel_name}\n") channel_info_file.write(f"Channel ID: {channel_id}\n") channel_info_file.write(f"Number of cached videos: {num_videos}\n") channel_info_file.write(f"Data saved on: {timestamp}\n") @@ -123,7 +122,7 @@ def main(): newest_video = video['snippet']['title'] os.system('cls' if os.name == 'nt' else 'clear') - print(f"{Fore.CYAN}channel: {Fore.YELLOW}{display_name}{Style.RESET_ALL}") + print(f"{Fore.CYAN}channel: {Fore.YELLOW}{channel_name}{Style.RESET_ALL}") print(f"{Fore.CYAN}videos: {Fore.YELLOW}{len(video_details)}{Style.RESET_ALL}") print(f"{Fore.CYAN}total length: {Fore.YELLOW}{total_duration}{Style.RESET_ALL}") print(f"{Fore.CYAN}est size: {Fore.YELLOW}{total_size_estimate_str}{Style.RESET_ALL}") @@ -159,7 +158,7 @@ def main(): total_size_str = f"{total_size / (1024 * 1024):.2f} MB" with open(os.path.join(base_path, f'{channel_id}_post_download_info.txt'), 'w', encoding='utf-8') as info_file: - info_file.write(f"channel: {display_name}\n") + info_file.write(f"channel: {channel_name}\n") info_file.write(f"videos downloaded: {len(video_details)}\n") info_file.write(f"time it took: {elapsed_time}\n") info_file.write(f"est size: {total_size_estimate_str}\n") diff --git a/utils/ytutils/get.py b/utils/ytutils/get.py index 033fa7c..8aa7bf3 100644 --- a/utils/ytutils/get.py +++ b/utils/ytutils/get.py @@ -11,9 +11,7 @@ def get_channel_id(channel_name): maxResults=1 ) response = request.execute() - channel_id = response['items'][0]['snippet']['channelId'] - display_name = response['items'][0]['snippet']['title'] - return channel_id, display_name + return response['items'][0]['snippet']['channelId'] def get_video_ids(channel_id): video_ids = [] diff --git a/utils/ytutils/ythelper.py b/utils/ytutils/ythelper.py index c6d51ee..5ff6aae 100644 --- a/utils/ytutils/ythelper.py +++ b/utils/ytutils/ythelper.py @@ -1,5 +1,5 @@ import re -from datetime import timedelta, datetime +from datetime import timedelta def parse_duration(duration): match = re.match(r'PT(\d+H)?(\d+M)?(\d+S)?', duration) @@ -13,11 +13,4 @@ def is_short(video): print(f"Skipping video {video.get('snippet', {}).get('title', 'Unknown')} due to missing duration info.") return False duration = parse_duration(video['contentDetails']['duration']) - return duration < timedelta(minutes=1) - -def save_channel_info(channel_id, display_name, video_count, save_path): - with open(save_path, 'w') as file: - file.write(f"Channel Name: {display_name}\n") - file.write(f"Channel ID: {channel_id}\n") - file.write(f"Number of cached videos: {video_count}\n") - file.write(f"Data saved on: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n") + return duration < timedelta(minutes=1) \ No newline at end of file