From 574d3d48df497902caabfcc33662481649967577 Mon Sep 17 00:00:00 2001 From: Valeri Gokadze Date: Tue, 30 Jan 2024 12:19:43 +0400 Subject: [PATCH] Added checker for deleted playlists and albums --- checkdb.sh | 1 + scripts/checker.dart | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 checkdb.sh create mode 100644 scripts/checker.dart diff --git a/checkdb.sh b/checkdb.sh new file mode 100644 index 000000000..f73f6743e --- /dev/null +++ b/checkdb.sh @@ -0,0 +1 @@ +dart scripts/checker.dart > checker.txt \ No newline at end of file diff --git a/scripts/checker.dart b/scripts/checker.dart new file mode 100644 index 000000000..7d4357f39 --- /dev/null +++ b/scripts/checker.dart @@ -0,0 +1,26 @@ +// ignore_for_file: avoid_print + +import 'package:musify/DB/albums.db.dart'; +import 'package:musify/DB/playlists.db.dart'; +import 'package:youtube_explode_dart/youtube_explode_dart.dart'; + +final _yt = YoutubeExplode(); +List playlists = [...playlistsDB, ...albumsDB]; + +void main() async { + print('PLAYLISTS AND ALBUMS CHECKING RESULT:'); + print(' '); + for (final playlist in playlists) { + final plist = await _yt.playlists.get(playlist['ytid']); + + if (plist.videoCount == null) { + if (playlist['isAlbum'] != null && playlist['isAlbum']) { + print('> The album with the ID ${playlist['ytid']} does not exist.'); + } else { + print('> The playlist with the ID ${playlist['ytid']} does not exist.'); + } + } + } + print(' '); + print('The checking process is done'); +}