From deea6b32a4f82590c1ce2426f44c90fcf1b0f488 Mon Sep 17 00:00:00 2001 From: Mike Nolan Date: Sun, 28 Dec 2025 23:22:42 -0600 Subject: [PATCH] Make subscriptions quicker --- .../src/YouTubeDownloader.tcross | 48 ++++++++----------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/Tesses.YouTubeDownloader/src/YouTubeDownloader.tcross b/Tesses.YouTubeDownloader/src/YouTubeDownloader.tcross index f95662d..0aa8020 100644 --- a/Tesses.YouTubeDownloader/src/YouTubeDownloader.tcross +++ b/Tesses.YouTubeDownloader/src/YouTubeDownloader.tcross @@ -952,7 +952,6 @@ class TYTD.Downloader { if(!notify && downloadRes == Resolution.NoDownload) continue; var cid = sub.channelId; - var newVideos = []; each(var batch : this.QueryPlaylistItems($"UU{cid.Substring(2)}",false)) { @@ -960,29 +959,27 @@ class TYTD.Downloader { { if(this.GetVideo(videoId) == null) + { newVideos.Add(videoId); + if(notify) + { + this.PutVideoInfoIfNotExists(videoId); + var res = this.GetVideo(id); + if(res != null) + this.Bell.Invoke(this,{ + Video = res + }); + } + if(downloadRes != Resolution.NoDownload) + { + this.DownloadVideo(id,downloadRes); + } + } } } - if(notify) - { - each(var id : newVideos) - { - this.PutVideoInfoIfNotExists(id); - var res = this.GetVideo(id); - if(res != null) - this.Bell.Invoke(this,{ - Video = res - }); - } - } - if(downloadRes != Resolution.NoDownload) - { - each(var id : newVideos) - { - this.DownloadVideo(id,downloadRes); - } - } + + } } @@ -1570,14 +1567,9 @@ class TYTD.Downloader { var response = Net.Http.MakeRequest(url,requestData); if(response.StatusCode != 200) throw "Not success"; const text = response.ReadAsString(); - var data = {}; - try { - data = Json.Decode(text); - } catch(ex) { - this.Storage.CreateDirectory(/"CorruptedJson"); - FS.WriteAllText(this.Storage,/"CorruptedJson"/$"{DateTime.NowEpoch}.json", text); - throw ex; - } + var data = Json.Decode(text); + + var cr = data.contents.twoColumnWatchNextResults.playlist.playlist; if(cr == null || cr == undefined) {