From a8658fdc4c72483b27f21fe777c03ad706c4ecaa Mon Sep 17 00:00:00 2001 From: Mike Nolan Date: Fri, 16 Oct 2026 00:00:56 -0500 Subject: [PATCH] Fix some songs not downloading hopefully --- .gitea/workflows/work.yml | 0 .onedev-buildspec.yml | 33 ------------------------------ Program.cs | 43 +++++++++++++++++++++------------------ 3 files changed, 23 insertions(+), 53 deletions(-) create mode 100644 .gitea/workflows/work.yml delete mode 100644 .onedev-buildspec.yml diff --git a/.gitea/workflows/work.yml b/.gitea/workflows/work.yml new file mode 100644 index 0000000..e69de29 diff --git a/.onedev-buildspec.yml b/.onedev-buildspec.yml deleted file mode 100644 index 15456d8..0000000 --- a/.onedev-buildspec.yml +++ /dev/null @@ -1,33 +0,0 @@ -version: 43 -jobs: -- name: build - steps: - - type: CheckoutStep - name: Checkout code - cloneCredential: - type: DefaultCredential - withLfs: true - withSubmodules: true - cloneDepth: 1 - condition: SUCCESSFUL - optional: false - - type: BuildImageStep - name: build image - output: - type: RegistryOutput - tags: onedev.site.tesses.net/tytd2025/tytdcompanion/tytdcompanion:latest - registryLogins: - - registryUrl: '@server_url@' - userName: '@job_token@' - passwordSecret: dockersecret - condition: SUCCESSFUL - optional: false - triggers: - - type: BranchUpdateTrigger - branches: master - userMatch: anyone - projects: tytd2025/tytdcompanion - retryCondition: never - maxRetries: 3 - retryDelay: 30 - timeout: 14400 diff --git a/Program.cs b/Program.cs index 860e0b4..a2cce72 100644 --- a/Program.cs +++ b/Program.cs @@ -17,6 +17,7 @@ using YoutubeExplode.Search; using YouTubeMusicAPI.Client; using YouTubeMusicAPI.Models.Search; using YouTubeMusicAPI.Pagination; +using System.Net.Http.Headers; @@ -420,7 +421,7 @@ namespace Tesses.YouTubeDownloader2025Companion { VideoTitle = webhook.Video.Title; - ChannelTitle = webhook.Video.Channel; + ChannelTitle = webhook.Video.Channel; } break; case "VideoFinished": @@ -642,7 +643,7 @@ namespace Tesses.YouTubeDownloader2025Companion routeServer.Add("/music/fix-song", EnsureLoggedin(FixIncorrectPost), "POST"); routeServer.Add("/fix-song-index", EnsureLoggedin(FixSongIndexGet)); routeServer.Add("/fix-song-index", EnsureLoggedin(FixSongIndexPost), "POST"); - + routeServer.Add("/music/artist", EnsureLoggedin(Artist)); routeServer.Add("/music/myartist", EnsureLoggedin(MyArtist)); @@ -769,7 +770,7 @@ namespace Tesses.YouTubeDownloader2025Companion } private static async Task ApiUnavailable(ServerContext ctx) { - + if (!ctx.QueryParams.TryGetFirstInt64("offset", out var offset)) offset = 0; @@ -782,7 +783,7 @@ namespace Tesses.YouTubeDownloader2025Companion await ctx.SendJsonAsync(songs); } } - + private static async Task ApiSongs(ServerContext ctx) { if (!ctx.QueryParams.TryGetFirst("q", out var q)) @@ -896,12 +897,14 @@ namespace Tesses.YouTubeDownloader2025Companion string path = mId.ToString(); if (File.Exists(path)) { - ContentDisposition disposition = new ContentDisposition(); - disposition.FileName = Path.GetFileName(path); - disposition.Inline = inline; - disposition.ModificationDate = File.GetLastWriteTime(path); - disposition.CreationDate = File.GetCreationTime(path); - ctx.ResponseHeaders["Content-Disposition"] = [disposition.ToString()]; + string filename = Path.GetFileName(path); + var cd = new ContentDispositionHeaderValue(inline ? "inline":"attachment"); + + cd.ModificationDate = File.GetLastWriteTime(path); + cd.CreationDate = File.GetCreationTime(path); + cd.FileName = filename; + cd.FileNameStar = filename; // auto-encodes to RFC 5987 + ctx.ResponseHeaders["Content-Disposition"] = [cd.ToString()]; await ctx.SendFileAsync(path); return; } @@ -949,7 +952,7 @@ namespace Tesses.YouTubeDownloader2025Companion if(cfg is not null) { cfg.ThumbnailsThroughTYTD = tytdthumbnail; - + File.WriteAllText(AuthConfigPath, JsonConvert.SerializeObject(cfg)); } } @@ -999,7 +1002,7 @@ namespace Tesses.YouTubeDownloader2025Companion } - + public static async Task GetVideoIdFromSong(AlbumSongQuery.AlbumSongQueryMedia.AlbumSongQueryMediaTrack.AlbumSongQueryMediaTrackRecording recording, string albumName) { using (var db = new Database()) @@ -1454,7 +1457,7 @@ namespace Tesses.YouTubeDownloader2025Companion } } - + public static async Task FixIncorrectPost(ServerContext ctx) { ctx.ParseBody(); @@ -1584,7 +1587,7 @@ namespace Tesses.YouTubeDownloader2025Companion Song? song = null; using (var db = new Database()) { - + await foreach (var item in db.GetMediaEntriesAsync(songId.ToString())) { entries.Add(item); @@ -1704,11 +1707,11 @@ namespace Tesses.YouTubeDownloader2025Companion { if(ctx.QueryParams.TryGetFirstGuid("id",out var id)) { - + var songResp = await MusicBrainzRequestAsync($"/ws/2/recording/{HttpUtility.UrlEncode(id.ToString())}/?fmt=json&inc=artist-credits+releases"); if(songResp is not null) { - + List links = new List(); @@ -1737,7 +1740,7 @@ namespace Tesses.YouTubeDownloader2025Companion var songQuery = await MusicBrainzRequestAsync($"/ws/2/recording?query={HttpUtility.UrlEncode(q)}&fmt=json&offset={(page - 1) * 25}&limit=25"); if (songQuery is not null) { - + foreach(var item in songQuery.Recordings) { @@ -1760,14 +1763,14 @@ namespace Tesses.YouTubeDownloader2025Companion songs.Add(new SongLink(builder.ToString(),item.Id.ToString())); } - + } - + } await ctx.SendTextAsync(Pages.SongListing(q,songs,page)); } - + public static async Task Artists(ServerContext ctx) {