diff --git a/checkstillexist.py b/checkstillexist.py index 29425e0..9671d82 100644 --- a/checkstillexist.py +++ b/checkstillexist.py @@ -3,33 +3,23 @@ import os import shutil def validate_youtube_url(url): - """YouTube URL'sinin geçerliliğini ve video ID'sini kontrol eder.""" if 'youtube.com/watch?v=' not in url and 'music.youtube.com/watch?v=' not in url: return False, None, None try: - # URL'den video ID'sini güvenli şekilde çıkar vid = url.split('v=')[1].split('&')[0].split('#')[0] - if len(vid) != 11: # YouTube video ID'leri 11 karakterdir + if len(vid) != 11: return False, None, None except: - return False, None, None - - # Provider tipini belirle + return False, None, None provider = 'YTM' if 'music.youtube.com' in url else 'YT' - - # URL'nin gerçekten erişilebilir olduğunu kontrol et yt_opts = {'quiet': True, 'ignoreerrors': True} with yt_dlp.YoutubeDL(yt_opts) as ydl: info = ydl.extract_info(url, download=False) - return bool(info), vid, provider def process_musiclist(): - # 1. Orijinal dosyanın yedeğini al shutil.copyfile('musiclist.txt', 'musiclist_backup.txt') - - # 2. Geçici liste için yeni dosya oluştur temp_lines = [] with open('musiclist.txt', 'r') as f: for line_num, line in enumerate(f, 1): @@ -37,60 +27,55 @@ def process_musiclist(): if not line: temp_lines.append(line) continue - try: musicname, old_vid, provider = line.split('---') musicname = musicname.strip() old_vid = old_vid.strip() provider = provider.strip() except: - print(f"⚠️ Hatalı satır formatı (satır {line_num}): {line}") + print(f"⚠️ Invalid line format (line {line_num}): {line}") temp_lines.append(line) continue - # 3. Mevcut URL'yi kontrol et base_url = f'https://{"music." if provider=="YTM" else ""}youtube.com/watch?v={old_vid}' is_valid, _, _ = validate_youtube_url(base_url) if is_valid: temp_lines.append(line) continue - - # 4. Geçersizse kullanıcıdan yeni URL iste - print(f"\n🔴 Geçersiz: {musicname}") - print(f"Mevcut URL: {base_url}") + + print(f"\n🔴 Invalid: {musicname}") + print(f"Current URL: {base_url}") while True: - new_url = input("Yeni YouTube URL'si girin (iptal için 'x'): ").strip() + new_url = input("Enter new YouTube URL (cancel with 'x'): ").strip() if new_url.lower() == 'x': - temp_lines.append(line) # Orijinal satırı koru - print("İptal edildi, orijinal kayıt korundu") + temp_lines.append(line) + print("Cancelled, original entry preserved") break is_valid, vid, detected_provider = validate_youtube_url(new_url) if is_valid: new_line = f"{musicname} --- {vid} --- {detected_provider}" temp_lines.append(new_line) - print(f"Güncellendi: {new_line}") + print(f"Updated: {new_line}") break - print("❌ Geçersiz URL veya video! Tekrar deneyin.") - - # 5. Değişiklikleri onayla + print("❌ Invalid URL or video! Try again.") + print("\n" + "═"*50) - print(f"Toplam {len(temp_lines)} kayıt işlendi") - confirmation = input("Değişiklikleri kaydetmek istiyor musunuz? (E/H): ").strip().lower() + print(f"Total {len(temp_lines)} entries processed") + confirmation = input("Save changes? (Y/N): ").strip().lower() - if confirmation == 'e': - # 6. Orijinal dosyayı güncelle + if confirmation == 'y': with open('musiclist.txt', 'w') as f: f.write('\n'.join(temp_lines)) - print("✔️ Müzik listesi başarıyla güncellendi!") - print("Orijinal dosyanın yedeği: musiclist_backup.txt") + print("✔️ Music list updated successfully!") + print("Backup of original file: musiclist_backup.txt") else: - print("❌ Değişiklikler iptal edildi, dosya değişmedi") + print("❌ Changes discarded, file unchanged") if __name__ == "__main__": - print("Orijinal dosyanızın yedeği otomatik alınacaktır\n") + print("A backup of your original file will be created automatically\n") if not os.path.exists('musiclist.txt'): - print("Hata: musiclist.txt bulunamadı!") + print("Error: musiclist.txt not found!") exit() process_musiclist() diff --git a/main.py b/main.py index a53c774..221577f 100644 --- a/main.py +++ b/main.py @@ -12,6 +12,7 @@ def get_download_path(): '/storage/emulated/0/Music', '/sdcard/Music', os.path.join(os.environ.get('HOME', ''), 'Music'), + os.path.join(os.environ.get('HOME', ''), 'Multimedia', 'Music'), os.path.join(os.getcwd(), 'music') ] diff --git a/setemptyalbumname.py b/setemptyalbumname.py new file mode 100644 index 0000000..9f66c80 --- /dev/null +++ b/setemptyalbumname.py @@ -0,0 +1,62 @@ +import os +from mutagen.flac import FLAC +from mutagen.oggopus import OggOpus +from mutagen.oggvorbis import OggVorbis + +def get_music_location(): + possible_paths = [ + '/mnt/sdcard/Music', + '/storage/emulated/0/Music', + '/sdcard/Music', + os.path.join(os.environ.get('HOME', ''), 'Music'), + os.path.join(os.getcwd(), 'music') + ] + for path in possible_paths: + if os.path.exists(path): + return path + default_path = os.path.join(os.getcwd(), 'music') + os.makedirs(default_path, exist_ok=True) + return default_path + +def process_audio_file(file_path): + try: + file_ext = os.path.splitext(file_path)[1].lower() + + if file_ext == '.flac': + audio = FLAC(file_path) + elif file_ext == '.opus': + audio = OggOpus(file_path) + elif file_ext == '.ogg': + audio = OggVorbis(file_path) + else: + return False + + current_album = audio.get('album', [''])[0].strip() + + if current_album != '': + return False + + audio['album'] = 'Music' + audio.save() + return True + + except Exception as e: + print(f"Error: {os.path.basename(file_path)} - {str(e)}") + return False + +def update_album_info(): + music_folder = get_music_location() + updated_files = 0 + + for root, _, files in os.walk(music_folder): + for filename in files: + full_path = os.path.join(root, filename) + if process_audio_file(full_path): + updated_files += 1 + print(f"Fixed: {filename}") + + print(f"\nSuccessfully updated {updated_files} files with empty album tags") + +if __name__ == "__main__": + print("Empty Album Fixer") + update_album_info() diff --git a/steps.txt b/steps.txt new file mode 100644 index 0000000..3ef50ed --- /dev/null +++ b/steps.txt @@ -0,0 +1,9 @@ +For list: +playlisttotxt.py +For manually add: +addmusic.py + +checkduplicate.py +main.py +generatedatabase.py +addotherproviders.py