Fix some songs not downloading hopefully

This commit is contained in:
2026-10-16 00:00:56 -05:00
parent e62d9f5c1d
commit a8658fdc4c
3 changed files with 23 additions and 53 deletions
View File
-33
View File
@@ -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
+23 -20
View File
@@ -17,6 +17,7 @@ using YoutubeExplode.Search;
using YouTubeMusicAPI.Client; using YouTubeMusicAPI.Client;
using YouTubeMusicAPI.Models.Search; using YouTubeMusicAPI.Models.Search;
using YouTubeMusicAPI.Pagination; using YouTubeMusicAPI.Pagination;
using System.Net.Http.Headers;
@@ -420,7 +421,7 @@ namespace Tesses.YouTubeDownloader2025Companion
{ {
VideoTitle = webhook.Video.Title; VideoTitle = webhook.Video.Title;
ChannelTitle = webhook.Video.Channel; ChannelTitle = webhook.Video.Channel;
} }
break; break;
case "VideoFinished": case "VideoFinished":
@@ -642,7 +643,7 @@ namespace Tesses.YouTubeDownloader2025Companion
routeServer.Add("/music/fix-song", EnsureLoggedin(FixIncorrectPost), "POST"); routeServer.Add("/music/fix-song", EnsureLoggedin(FixIncorrectPost), "POST");
routeServer.Add("/fix-song-index", EnsureLoggedin(FixSongIndexGet)); routeServer.Add("/fix-song-index", EnsureLoggedin(FixSongIndexGet));
routeServer.Add("/fix-song-index", EnsureLoggedin(FixSongIndexPost), "POST"); routeServer.Add("/fix-song-index", EnsureLoggedin(FixSongIndexPost), "POST");
routeServer.Add("/music/artist", EnsureLoggedin(Artist)); routeServer.Add("/music/artist", EnsureLoggedin(Artist));
routeServer.Add("/music/myartist", EnsureLoggedin(MyArtist)); routeServer.Add("/music/myartist", EnsureLoggedin(MyArtist));
@@ -769,7 +770,7 @@ namespace Tesses.YouTubeDownloader2025Companion
} }
private static async Task ApiUnavailable(ServerContext ctx) private static async Task ApiUnavailable(ServerContext ctx)
{ {
if (!ctx.QueryParams.TryGetFirstInt64("offset", out var offset)) if (!ctx.QueryParams.TryGetFirstInt64("offset", out var offset))
offset = 0; offset = 0;
@@ -782,7 +783,7 @@ namespace Tesses.YouTubeDownloader2025Companion
await ctx.SendJsonAsync(songs); await ctx.SendJsonAsync(songs);
} }
} }
private static async Task ApiSongs(ServerContext ctx) private static async Task ApiSongs(ServerContext ctx)
{ {
if (!ctx.QueryParams.TryGetFirst("q", out var q)) if (!ctx.QueryParams.TryGetFirst("q", out var q))
@@ -896,12 +897,14 @@ namespace Tesses.YouTubeDownloader2025Companion
string path = mId.ToString(); string path = mId.ToString();
if (File.Exists(path)) if (File.Exists(path))
{ {
ContentDisposition disposition = new ContentDisposition(); string filename = Path.GetFileName(path);
disposition.FileName = Path.GetFileName(path); var cd = new ContentDispositionHeaderValue(inline ? "inline":"attachment");
disposition.Inline = inline;
disposition.ModificationDate = File.GetLastWriteTime(path); cd.ModificationDate = File.GetLastWriteTime(path);
disposition.CreationDate = File.GetCreationTime(path); cd.CreationDate = File.GetCreationTime(path);
ctx.ResponseHeaders["Content-Disposition"] = [disposition.ToString()]; cd.FileName = filename;
cd.FileNameStar = filename; // auto-encodes to RFC 5987
ctx.ResponseHeaders["Content-Disposition"] = [cd.ToString()];
await ctx.SendFileAsync(path); await ctx.SendFileAsync(path);
return; return;
} }
@@ -949,7 +952,7 @@ namespace Tesses.YouTubeDownloader2025Companion
if(cfg is not null) if(cfg is not null)
{ {
cfg.ThumbnailsThroughTYTD = tytdthumbnail; cfg.ThumbnailsThroughTYTD = tytdthumbnail;
File.WriteAllText(AuthConfigPath, JsonConvert.SerializeObject(cfg)); File.WriteAllText(AuthConfigPath, JsonConvert.SerializeObject(cfg));
} }
} }
@@ -999,7 +1002,7 @@ namespace Tesses.YouTubeDownloader2025Companion
} }
public static async Task<VideoId?> GetVideoIdFromSong(AlbumSongQuery.AlbumSongQueryMedia.AlbumSongQueryMediaTrack.AlbumSongQueryMediaTrackRecording recording, string albumName) public static async Task<VideoId?> GetVideoIdFromSong(AlbumSongQuery.AlbumSongQueryMedia.AlbumSongQueryMediaTrack.AlbumSongQueryMediaTrackRecording recording, string albumName)
{ {
using (var db = new Database()) using (var db = new Database())
@@ -1454,7 +1457,7 @@ namespace Tesses.YouTubeDownloader2025Companion
} }
} }
public static async Task FixIncorrectPost(ServerContext ctx) public static async Task FixIncorrectPost(ServerContext ctx)
{ {
ctx.ParseBody(); ctx.ParseBody();
@@ -1584,7 +1587,7 @@ namespace Tesses.YouTubeDownloader2025Companion
Song? song = null; Song? song = null;
using (var db = new Database()) using (var db = new Database())
{ {
await foreach (var item in db.GetMediaEntriesAsync(songId.ToString())) await foreach (var item in db.GetMediaEntriesAsync(songId.ToString()))
{ {
entries.Add(item); entries.Add(item);
@@ -1704,11 +1707,11 @@ namespace Tesses.YouTubeDownloader2025Companion
{ {
if(ctx.QueryParams.TryGetFirstGuid("id",out var id)) if(ctx.QueryParams.TryGetFirstGuid("id",out var id))
{ {
var songResp = await MusicBrainzRequestAsync<MusicBrainzSongInfo>($"/ws/2/recording/{HttpUtility.UrlEncode(id.ToString())}/?fmt=json&inc=artist-credits+releases"); var songResp = await MusicBrainzRequestAsync<MusicBrainzSongInfo>($"/ws/2/recording/{HttpUtility.UrlEncode(id.ToString())}/?fmt=json&inc=artist-credits+releases");
if(songResp is not null) if(songResp is not null)
{ {
List<AlbumLink> links = new List<AlbumLink>(); List<AlbumLink> links = new List<AlbumLink>();
@@ -1737,7 +1740,7 @@ namespace Tesses.YouTubeDownloader2025Companion
var songQuery = await MusicBrainzRequestAsync<SongQuery>($"/ws/2/recording?query={HttpUtility.UrlEncode(q)}&fmt=json&offset={(page - 1) * 25}&limit=25"); var songQuery = await MusicBrainzRequestAsync<SongQuery>($"/ws/2/recording?query={HttpUtility.UrlEncode(q)}&fmt=json&offset={(page - 1) * 25}&limit=25");
if (songQuery is not null) if (songQuery is not null)
{ {
foreach(var item in songQuery.Recordings) foreach(var item in songQuery.Recordings)
{ {
@@ -1760,14 +1763,14 @@ namespace Tesses.YouTubeDownloader2025Companion
songs.Add(new SongLink(builder.ToString(),item.Id.ToString())); songs.Add(new SongLink(builder.ToString(),item.Id.ToString()));
} }
} }
} }
await ctx.SendTextAsync(Pages.SongListing(q,songs,page)); await ctx.SendTextAsync(Pages.SongListing(q,songs,page));
} }
public static async Task Artists(ServerContext ctx) public static async Task Artists(ServerContext ctx)
{ {