diff --git a/MusicDownloader/Class/CmnUtil.cs b/MusicDownloader/Class/CmnUtil.cs
index dc79648..58dbe88 100644
--- a/MusicDownloader/Class/CmnUtil.cs
+++ b/MusicDownloader/Class/CmnUtil.cs
@@ -33,21 +33,81 @@ namespace MusicDownloader.Class
}
///
- /// YouTube動画のタイトルから不要な装飾記号を除去し、アーティスト名と曲名を推測・抽出する
+ /// YouTubeチャンネル名(アップローダー名)から「 - Topic」などの自動付与サフィックスを除去・整形する
+ ///
+ public static string CleanChannelName(string? uploader)
+ {
+ if (string.IsNullOrWhiteSpace(uploader)) return "";
+
+ var clean = uploader.Trim();
+ // "xxx - Topic" や "xxx - トピック" の除去
+ clean = Regex.Replace(clean, @"\s*[-–—]\s*(?:Topic|トピック)$", "", RegexOptions.IgnoreCase).Trim();
+ // "xxx Official Channel" などの除去
+ clean = Regex.Replace(clean, @"\s*(?:Official\s*Channel|Official|公式)$", "", RegexOptions.IgnoreCase).Trim();
+
+ return clean;
+ }
+
+ ///
+ /// 動画タイトルから不要な装飾記号・タグ文字列を除去する
+ ///
+ public static string CleanVideoTitle(string rawTitle)
+ {
+ if (string.IsNullOrWhiteSpace(rawTitle)) return "";
+
+ var cleaned = rawTitle;
+
+ // 【MV】, [Official Video], (Audio), 【オリジナル曲】などの装飾カッコを除去
+ cleaned = Regex.Replace(cleaned, @"(?i)[\(\[\{【「『](?:MV|Music\s*Video|Official(?:\s*Music\s*Video|\s*Video|\s*Audio)?|Audio|Full|Cover|歌ってみた|オリジナル(?:曲)?|HQ|HD|4K|Lyric(?:\s*Video)?|Short\s*ver|Special\s*ver)[^\]\)\}】」』]*[\)\]\}】」』]", "", RegexOptions.Compiled).Trim();
+
+ // カッコ外に残った "Official Music Video" 等の単独テキストを除去
+ cleaned = Regex.Replace(cleaned, @"(?i)\b(?:Official\s*Music\s*Video|Official\s*Video|Official\s*Audio|Music\s*Video)\b", "", RegexOptions.Compiled).Trim();
+
+ // 末尾や先頭に残った不要なハイフンやスラッシュを除去
+ cleaned = Regex.Replace(cleaned, @"^[\s\-–—//||]+|[\s\-–—//||]+$", "", RegexOptions.Compiled).Trim();
+
+ return cleaned;
+ }
+
+ ///
+ /// YouTube動画のタイトルとアップローダー名から、アーティスト名と曲名を高度に推測・抽出する
///
public static (string Artist, string Title) ParseArtistAndTitle(string rawTitle, string uploader)
{
+ var cleanUploader = CleanChannelName(uploader);
+
if (string.IsNullOrWhiteSpace(rawTitle))
{
- return (uploader, "Unknown");
+ return (!string.IsNullOrWhiteSpace(cleanUploader) ? cleanUploader : "Unknown", "Unknown");
}
- // 【MV】, [Official Video], (Audio), 【オリジナル曲】などの装飾文字を除去
- var cleaned = Regex.Replace(rawTitle, @"(?i)[\(\[\{【「『](?:MV|Music Video|Official|Audio|Full|Cover|歌ってみた|オリジナル|HQ|HD|4K)[^\]\)\}】」』]*[\)\]\}】」』]", "", RegexOptions.Compiled).Trim();
- cleaned = Regex.Replace(cleaned, @"(?i)(?:MV|Music Video|Official Video|Official Audio)", "", RegexOptions.Compiled).Trim();
+ // 1. カッコによる曲名囲みパターン: アーティスト「曲名」 または アーティスト『曲名』
+ var bracketMatch = Regex.Match(rawTitle, @"^(.*?)\s*[「『""]([^「『""」』]+)[」』""]\s*(.*)$", RegexOptions.Compiled);
+ if (bracketMatch.Success)
+ {
+ var candidateArtist = bracketMatch.Groups[1].Value.Trim();
+ var candidateTitle = bracketMatch.Groups[2].Value.Trim();
- // "Artist - Title" または "Artist / Title" の形式を判定
- var match = Regex.Match(cleaned, @"^(.*?)\s*[-–—//]\s*(.*)$", RegexOptions.Compiled);
+ candidateArtist = CleanVideoTitle(candidateArtist);
+ candidateTitle = CleanVideoTitle(candidateTitle);
+
+ // アーティスト候補が空の場合、アップローダーを適用
+ if (string.IsNullOrWhiteSpace(candidateArtist) && !string.IsNullOrWhiteSpace(cleanUploader))
+ {
+ candidateArtist = cleanUploader;
+ }
+
+ if (!string.IsNullOrWhiteSpace(candidateArtist) && !string.IsNullOrWhiteSpace(candidateTitle))
+ {
+ return (candidateArtist, candidateTitle);
+ }
+ }
+
+ // 2. 装飾記号を除去したクリーンタイトルを生成
+ var cleaned = CleanVideoTitle(rawTitle);
+
+ // 3. 区切り記号(ハイフン、スラッシュ、パイプ等)で分割判定
+ var match = Regex.Match(cleaned, @"^(.*?)\s*[-–—//||]\s*(.*)$", RegexOptions.Compiled);
if (match.Success)
{
var part1 = match.Groups[1].Value.Trim();
@@ -55,12 +115,35 @@ namespace MusicDownloader.Class
if (!string.IsNullOrEmpty(part1) && !string.IsNullOrEmpty(part2))
{
+ // part1 と part2 のどちらがアーティストかを判定
+ // チャンネル名と照合
+ if (!string.IsNullOrWhiteSpace(cleanUploader))
+ {
+ // part2 がチャンネル名と一致する場合 -> 「曲名 - アーティスト」パターン
+ if (part2.Equals(cleanUploader, StringComparison.OrdinalIgnoreCase) ||
+ part2.Contains(cleanUploader, StringComparison.OrdinalIgnoreCase))
+ {
+ return (cleanUploader, part1);
+ }
+
+ // part1 がチャンネル名と一致する場合 -> 「アーティスト - 曲名」パターン
+ if (part1.Equals(cleanUploader, StringComparison.OrdinalIgnoreCase) ||
+ part1.Contains(cleanUploader, StringComparison.OrdinalIgnoreCase))
+ {
+ return (part1, part2);
+ }
+ }
+
+ // 既定では「Artist - Title」と仮定
return (part1, part2);
}
}
- // 区切りがない場合はアップローダーをアーティストとし、タイトルを曲名とする
- return (!string.IsNullOrWhiteSpace(uploader) ? uploader : "Unknown", string.IsNullOrWhiteSpace(cleaned) ? rawTitle : cleaned);
+ // 4. 区切りがない場合はアップローダーをアーティスト、タイトルを曲名とする
+ var finalArtist = !string.IsNullOrWhiteSpace(cleanUploader) ? cleanUploader : "Unknown";
+ var finalTitle = !string.IsNullOrWhiteSpace(cleaned) ? cleaned : rawTitle;
+
+ return (finalArtist, finalTitle);
}
///
diff --git a/MusicDownloader/Class/Downloader/YoutubeDownloader.cs b/MusicDownloader/Class/Downloader/YoutubeDownloader.cs
index 64f9c38..288aaf6 100644
--- a/MusicDownloader/Class/Downloader/YoutubeDownloader.cs
+++ b/MusicDownloader/Class/Downloader/YoutubeDownloader.cs
@@ -26,6 +26,18 @@ namespace MusicDownloader.Class.Downloader
[JsonPropertyName("uploader")]
public string? Uploader { get; set; }
+ [JsonPropertyName("channel")]
+ public string? Channel { get; set; }
+
+ [JsonPropertyName("track")]
+ public string? Track { get; set; }
+
+ [JsonPropertyName("artist")]
+ public string? Artist { get; set; }
+
+ [JsonPropertyName("album")]
+ public string? Album { get; set; }
+
[JsonPropertyName("duration")]
public double? Duration { get; set; }
@@ -78,17 +90,19 @@ namespace MusicDownloader.Class.Downloader
}
///
- /// yt-dlpを用いたYouTubeダウンロードおよびメタデータ/歌詞付与を行うクラス
+ /// 高音質変換・外部検索メタデータ付与・歌詞連携を行うダウンロード処理クラス
///
public class YoutubeDownloader
{
private readonly string _ytDlpPath;
private readonly LyricsManager _lyricsManager;
+ private readonly MusicMetadataClient _metadataClient;
- public YoutubeDownloader(string ytDlpPath, LyricsManager lyricsManager)
+ public YoutubeDownloader(string ytDlpPath, LyricsManager lyricsManager, MusicMetadataClient metadataClient)
{
_ytDlpPath = ytDlpPath;
_lyricsManager = lyricsManager;
+ _metadataClient = metadataClient;
}
///
@@ -123,7 +137,7 @@ namespace MusicDownloader.Class.Downloader
}
///
- /// プレイリスト全体のダウンロードおよび歌詞・メタデータ処理を実行する
+ /// プレイリスト全体のダウンロードおよびメタデータ・歌詞付与を実行する
///
public async Task ProcessPlaylistAsync(string playlistUrl, string outputBaseDir)
{
@@ -155,7 +169,7 @@ namespace MusicDownloader.Class.Downloader
// 単一動画URLまたはエントリがフラット取得できなかった場合、直接ダウンロード
LogManager.AddLog($"プレイリストのエントリが見つからないか単一動画URLです。直接ダウンロードを試行します。");
- await DownloadAndProcessSingleAsync(playlistUrl, 1, 1, targetFolder, sanitizedPlaylistName, null, playlistInfo?.Uploader);
+ await DownloadAndProcessSingleAsync(playlistUrl, 1, 1, targetFolder, sanitizedPlaylistName, null);
return;
}
@@ -173,12 +187,12 @@ namespace MusicDownloader.Class.Downloader
LogManager.AddLog($"--------------------------------------------------------------------------------");
LogManager.AddLog($"[{videoIndex}/{totalCount}] 処理開始: {entry.Title ?? entry.Id}");
- await DownloadAndProcessSingleAsync(videoUrl, videoIndex, totalCount, targetFolder, sanitizedPlaylistName, entry, playlistInfo?.Uploader);
+ await DownloadAndProcessSingleAsync(videoUrl, videoIndex, totalCount, targetFolder, sanitizedPlaylistName, entry);
- // サーバー負荷軽減および確実性のための待機(1.5秒)
- await Task.Delay(1500);
+ // サーバー負荷軽減および省メモリ・安定化のためのクールダウン待機(3秒)
+ await Task.Delay(3000);
- // 1曲ごとにメモリを速やかに解放(省メモリ化)
+ // 1曲ごとに不要メモリを速やかに解放(省メモリ化)
GC.Collect(1, GCCollectionMode.Optimized, false);
}
@@ -188,14 +202,16 @@ namespace MusicDownloader.Class.Downloader
LogManager.AddSuccess($"================================================================================");
}
+ ///
+ /// 1曲のダウンロード・高音質Opus変換・外部楽曲メタデータ解決・タグ付与を実行する
+ ///
private async Task DownloadAndProcessSingleAsync(
string videoUrl,
uint index,
uint totalCount,
string targetFolder,
string playlistName,
- YtPlaylistEntry? entryInfo,
- string? playlistUploader)
+ YtPlaylistEntry? entryInfo)
{
var archiveFile = Path.Combine(targetFolder, "archive.txt");
var filePrefix = $"{index:D2} - ";
@@ -203,11 +219,19 @@ namespace MusicDownloader.Class.Downloader
// 出力ファイル名テンプレート
var outputTemplate = Path.Combine(targetFolder, $"{filePrefix}%(title)s.%(ext)s");
+ // 高音質変換およびブツブツ防止のためのyt-dlp・ffmpeg引数
+ // - 最高音質音声ストリームの選択 (-f bestaudio/best)
+ // - フラグメント並行数1でパケット抜け・順序乱れ・メモリ枯渇を防止
+ // - ffmpeg aresample=async=1000 によりタイムスタンプのドリフト・不連続を補正しプチプチ音を根絶
var arguments = new List
{
+ "-f", "bestaudio/best",
"--extract-audio",
"--audio-format", "opus",
"--audio-quality", "0",
+ "--postprocessor-args", "ExtractAudio:-af aresample=async=1000 -c:a libopus -b:a 160k -vbr on",
+ "--concurrent-fragments", "1",
+ "--buffer-size", "16K",
"--write-thumbnail",
"--convert-thumbnails", "jpg",
"--write-subs",
@@ -217,13 +241,14 @@ namespace MusicDownloader.Class.Downloader
"--no-abort-on-error",
"--retries", "10",
"--fragment-retries", "10",
+ "--retry-sleep", "3",
"--download-archive", archiveFile,
"-o", outputTemplate,
"--no-warnings",
videoUrl
};
- LogManager.AddLog($"ダウンロード実行中 (yt-dlp)...");
+ LogManager.AddLog($"ダウンロード&高音質変換実行中 (yt-dlp)...");
try
{
var cmdResult = await Cli.Wrap(_ytDlpPath)
@@ -259,43 +284,110 @@ namespace MusicDownloader.Class.Downloader
var targetOpus = opusFiles.OrderByDescending(f => File.GetLastWriteTime(f)).First();
var fileNameWithoutExt = Path.GetFileNameWithoutExtension(targetOpus);
- // 曲名とアーティスト名の正確な判定
+ // 音声ファイルの整合性検証(ブツブツ・破損チェック)
+ await VerifyAudioIntegrityAsync(targetOpus);
+
+ // -------------------------------------------------------------
+ // メタデータ(曲名・アーティスト・アルバム・アルバムアーティスト)の決定
+ // -------------------------------------------------------------
var rawTitle = fileNameWithoutExt.StartsWith(filePrefix) ? fileNameWithoutExt.Substring(filePrefix.Length) : fileNameWithoutExt;
var baseTitle = !string.IsNullOrWhiteSpace(entryInfo?.Title) ? entryInfo.Title : rawTitle;
- var uploader = entryInfo?.Uploader ?? "";
- var (artist, title) = CmnUtil.ParseArtistAndTitle(baseTitle, uploader);
+ var uploader = !string.IsNullOrWhiteSpace(entryInfo?.Channel) ? entryInfo.Channel : (entryInfo?.Uploader ?? "");
- // サムネイル画像の検索
- var thumbJpg = Path.ChangeExtension(targetOpus, ".jpg");
- string? thumbnailToUse = File.Exists(thumbJpg) ? thumbJpg : null;
+ // 1. タイトル文字列の初期パース
+ var (initialArtist, initialTitle) = CmnUtil.ParseArtistAndTitle(baseTitle, uploader);
+
+ // 2. yt-dlp の公式トラック/アーティストメタデータが存在すれば優先
+ if (!string.IsNullOrWhiteSpace(entryInfo?.Track))
+ {
+ initialTitle = entryInfo.Track;
+ }
+ if (!string.IsNullOrWhiteSpace(entryInfo?.Artist))
+ {
+ initialArtist = entryInfo.Artist;
+ }
+
+ LogManager.AddLog($"解析候補: [アーティスト: {initialArtist}] [曲名: {initialTitle}]");
+
+ // 3. 外部楽曲検索API (iTunes / LRCLIB) を呼び出して正確な公式メタデータを解決
+ string finalTitle = initialTitle;
+ string finalArtist = initialArtist;
+ string finalAlbum = !string.IsNullOrWhiteSpace(entryInfo?.Album) ? entryInfo.Album : playlistName;
+ string finalAlbumArtist = initialArtist; // 既定は楽曲のアーティスト
+ uint? finalYear = entryInfo?.GetYear();
+ string? downloadArtworkPath = null;
+
+ var resolvedMeta = await _metadataClient.ResolveMetadataAsync(
+ rawVideoTitle: baseTitle,
+ uploader: uploader,
+ parsedArtist: initialArtist,
+ parsedTitle: initialTitle,
+ durationSeconds: entryInfo?.Duration);
+
+ if (resolvedMeta != null)
+ {
+ finalTitle = resolvedMeta.Title;
+ finalArtist = resolvedMeta.Artist;
+ if (!string.IsNullOrWhiteSpace(resolvedMeta.Album))
+ {
+ finalAlbum = resolvedMeta.Album;
+ }
+ if (!string.IsNullOrWhiteSpace(resolvedMeta.AlbumArtist))
+ {
+ finalAlbumArtist = resolvedMeta.AlbumArtist;
+ }
+ if (resolvedMeta.Year.HasValue && resolvedMeta.Year.Value > 0)
+ {
+ finalYear = resolvedMeta.Year.Value;
+ }
+
+ // 高画質カバー画像が存在すればダウンロードして適用
+ if (!string.IsNullOrWhiteSpace(resolvedMeta.ArtworkUrl))
+ {
+ var highResArtPath = Path.Combine(targetFolder, $"{filePrefix}itunes_cover.jpg");
+ var downloadedArt = await _metadataClient.DownloadArtworkAsync(resolvedMeta.ArtworkUrl, highResArtPath);
+ if (downloadedArt != null)
+ {
+ downloadArtworkPath = downloadedArt;
+ }
+ }
+ }
+
+ // サムネイル画像の決定(高画質公式アートワーク > YouTubeサムネイル)
+ string? thumbnailToUse = downloadArtworkPath;
if (thumbnailToUse == null)
{
- var prefixJpgs = Directory.GetFiles(targetFolder, $"{filePrefix}*.jpg");
- if (prefixJpgs.Length > 0)
+ var thumbJpg = Path.ChangeExtension(targetOpus, ".jpg");
+ if (File.Exists(thumbJpg))
{
- thumbnailToUse = prefixJpgs[0];
+ thumbnailToUse = thumbJpg;
+ }
+ else
+ {
+ var prefixJpgs = Directory.GetFiles(targetFolder, $"{filePrefix}*.jpg");
+ if (prefixJpgs.Length > 0)
+ {
+ thumbnailToUse = prefixJpgs[0];
+ }
}
}
// 歌詞処理 (.lrc作成および歌詞テキスト取得)
- var lyrics = await _lyricsManager.ProcessLyricsAsync(targetOpus, title, artist, entryInfo?.Duration, targetFolder, filePrefix);
+ var lyrics = await _lyricsManager.ProcessLyricsAsync(targetOpus, finalTitle, finalArtist, entryInfo?.Duration, targetFolder, filePrefix);
- // 公開年(リリース年)の取得
- var year = entryInfo?.GetYear();
-
- // メタデータ (TagLibSharp) の書き込み(完全なメタデータ埋め込み)
+ // メタデータ (TagLibSharp) の書き込み(正確な曲名・アーティスト・アルバム・アルバムアーティスト)
AudioTagManager.ApplyMetadata(
opusPath: targetOpus,
- title: title,
- artist: artist,
- album: playlistName,
+ title: finalTitle,
+ artist: finalArtist,
+ album: finalAlbum,
trackNumber: index,
trackCount: totalCount,
- year: year,
+ year: finalYear,
lyrics: lyrics,
thumbnailPath: thumbnailToUse,
comment: videoUrl,
- albumArtist: playlistUploader);
+ albumArtist: finalAlbumArtist);
// プレイリスト代表カバー画像として cover.jpg が存在しなければコピー
var albumCoverPath = Path.Combine(targetFolder, "cover.jpg");
@@ -308,21 +400,55 @@ namespace MusicDownloader.Class.Downloader
catch { }
}
- // 不要な中間ファイル(.vttファイル)のクリーンアップ
+ // 一時ファイル(.vtt, 一時画像等)のクリーンアップ
CleanupTempFiles(targetFolder, filePrefix);
LogManager.AddSuccess($"[{index}/{totalCount}] 完了: {Path.GetFileName(targetOpus)}");
}
+ ///
+ /// ffmpegを用いて音声ファイルの整合性をチェック(破損やデコードエラーがないか検証)
+ ///
+ private async Task VerifyAudioIntegrityAsync(string opusPath)
+ {
+ try
+ {
+ var result = await Cli.Wrap("ffmpeg")
+ .WithArguments(new[] { "-v", "error", "-i", opusPath, "-f", "null", "-" })
+ .WithValidation(CommandResultValidation.None)
+ .ExecuteBufferedAsync();
+
+ if (result.ExitCode == 0 && string.IsNullOrWhiteSpace(result.StandardError))
+ {
+ LogManager.AddSuccess($"音声整合性チェック合格 (エラーなし): {Path.GetFileName(opusPath)}");
+ }
+ else if (!string.IsNullOrWhiteSpace(result.StandardError))
+ {
+ LogManager.AddWarning($"音声ファイル検証警告: {result.StandardError.Trim()}");
+ }
+ }
+ catch
+ {
+ // ffmpegがPATHに見当たらない等の場合はスキップ
+ }
+ }
+
+ ///
+ /// 中間一時ファイル(.vtt, .part, 一時画像)を削除
+ ///
private void CleanupTempFiles(string folder, string? prefix = null)
{
try
{
- var searchPattern = !string.IsNullOrEmpty(prefix) ? $"{prefix}*.vtt" : "*.vtt";
- var vttFiles = Directory.GetFiles(folder, searchPattern);
- foreach (var vtt in vttFiles)
+ var searchPattern = !string.IsNullOrEmpty(prefix) ? $"{prefix}*" : "*";
+ var files = Directory.GetFiles(folder, searchPattern);
+ foreach (var file in files)
{
- try { File.Delete(vtt); } catch { }
+ var ext = Path.GetExtension(file).ToLowerInvariant();
+ if (ext == ".vtt" || ext == ".part" || ext == ".ytdl" || file.EndsWith("itunes_cover.jpg"))
+ {
+ try { File.Delete(file); } catch { }
+ }
}
}
catch { }
diff --git a/MusicDownloader/Class/Metadata/AudioTagManager.cs b/MusicDownloader/Class/Metadata/AudioTagManager.cs
index dd61861..267c5ef 100644
--- a/MusicDownloader/Class/Metadata/AudioTagManager.cs
+++ b/MusicDownloader/Class/Metadata/AudioTagManager.cs
@@ -4,7 +4,7 @@ using System.IO;
namespace MusicDownloader.Class.Metadata
{
///
- /// TagLibSharpを用いてOpusファイルにメタデータ・歌詞・カバーアートを埋め込むクラス
+ /// TagLibSharpを用いてOpusファイルにメタデータ・歌詞・カバーアートを正確に埋め込むクラス
///
public static class AudioTagManager
{
@@ -37,8 +37,16 @@ namespace MusicDownloader.Class.Metadata
// 基本タグの設定
file.Tag.Title = title;
file.Tag.Performers = new[] { artist };
- file.Tag.AlbumArtists = new[] { !string.IsNullOrWhiteSpace(albumArtist) ? albumArtist : artist };
- file.Tag.Album = album;
+
+ // アルバムアーティストの正確な決定(空や異常値の場合は楽曲のアーティストを適用)
+ var resolvedAlbumArtist = (!string.IsNullOrWhiteSpace(albumArtist) && albumArtist != "Unknown")
+ ? albumArtist
+ : artist;
+ file.Tag.AlbumArtists = new[] { resolvedAlbumArtist };
+
+ // アルバム名の設定
+ file.Tag.Album = !string.IsNullOrWhiteSpace(album) ? album : title;
+
file.Tag.Track = trackNumber;
file.Tag.TrackCount = trackCount;
@@ -68,7 +76,8 @@ namespace MusicDownloader.Class.Metadata
var pic = new TagLib.Picture(thumbnailPath)
{
Type = TagLib.PictureType.FrontCover,
- Description = "Cover"
+ Description = "Cover",
+ MimeType = "image/jpeg"
};
file.Tag.Pictures = new TagLib.IPicture[] { pic };
}
@@ -80,7 +89,7 @@ namespace MusicDownloader.Class.Metadata
file.Save();
var yearStr = (year.HasValue && year.Value > 0) ? $" ({year.Value}年)" : "";
- LogManager.AddSuccess($"メタデータを埋め込みました: 「{artist} - {title}」{yearStr} [Track {trackNumber}/{trackCount}]");
+ LogManager.AddSuccess($"メタデータを埋め込みました: 「{artist} - {title}」{yearStr} [アルバム: {file.Tag.Album} / アルバムアーティスト: {resolvedAlbumArtist}] (Track {trackNumber}/{trackCount})");
return true;
}
catch (Exception ex)
diff --git a/MusicDownloader/Class/Metadata/MusicMetadataClient.cs b/MusicDownloader/Class/Metadata/MusicMetadataClient.cs
new file mode 100644
index 0000000..6dd5fee
--- /dev/null
+++ b/MusicDownloader/Class/Metadata/MusicMetadataClient.cs
@@ -0,0 +1,393 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net.Http;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+
+namespace MusicDownloader.Class.Metadata
+{
+ ///
+ /// 検索によって特定された確定楽曲メタデータ
+ ///
+ public class SongMetadataResult
+ {
+ /// 曲名
+ public string Title { get; set; } = "";
+
+ /// アーティスト名
+ public string Artist { get; set; } = "";
+
+ /// アルバム名
+ public string Album { get; set; } = "";
+
+ /// アルバムアーティスト名
+ public string AlbumArtist { get; set; } = "";
+
+ /// リリース年
+ public uint? Year { get; set; }
+
+ /// 高解像度カバー画像URL
+ public string? ArtworkUrl { get; set; }
+
+ /// 再生時間(秒)
+ public double? DurationSeconds { get; set; }
+ }
+
+ ///
+ /// iTunes Search API レスポンスモデル
+ ///
+ public class ITunesSearchResponse
+ {
+ [JsonPropertyName("resultCount")]
+ public int ResultCount { get; set; }
+
+ [JsonPropertyName("results")]
+ public List? Results { get; set; }
+ }
+
+ ///
+ /// iTunes 楽曲アイテムモデル
+ ///
+ public class ITunesSongItem
+ {
+ [JsonPropertyName("trackName")]
+ public string? TrackName { get; set; }
+
+ [JsonPropertyName("artistName")]
+ public string? ArtistName { get; set; }
+
+ [JsonPropertyName("collectionName")]
+ public string? CollectionName { get; set; }
+
+ [JsonPropertyName("collectionArtistName")]
+ public string? CollectionArtistName { get; set; }
+
+ [JsonPropertyName("releaseDate")]
+ public string? ReleaseDate { get; set; }
+
+ [JsonPropertyName("artworkUrl100")]
+ public string? ArtworkUrl100 { get; set; }
+
+ [JsonPropertyName("trackTimeMillis")]
+ public long? TrackTimeMillis { get; set; }
+ }
+
+ ///
+ /// iTunes Search API および LRCLIB を用いた楽曲メタデータ検索クライアント
+ ///
+ public class MusicMetadataClient
+ {
+ private readonly HttpClient _httpClient;
+
+ public MusicMetadataClient(HttpClient httpClient)
+ {
+ _httpClient = httpClient;
+ }
+
+ ///
+ /// 動画タイトル、アップローダー名、推測された曲名/アーティスト情報から公式楽曲メタデータを検索・補正する
+ ///
+ public async Task ResolveMetadataAsync(
+ string rawVideoTitle,
+ string uploader,
+ string parsedArtist,
+ string parsedTitle,
+ double? durationSeconds)
+ {
+ // 1. 検索クエリのバリエーションを生成
+ var searchQueries = BuildSearchQueries(rawVideoTitle, uploader, parsedArtist, parsedTitle);
+
+ // 2. iTunes Search API で検索
+ foreach (var query in searchQueries)
+ {
+ var iTunesResult = await SearchITunesAsync(query, parsedArtist, parsedTitle, durationSeconds);
+ if (iTunesResult != null)
+ {
+ LogManager.AddSuccess($"iTunes楽曲データベースと一致しました: 「{iTunesResult.Artist} - {iTunesResult.Title}」 (アルバム: {iTunesResult.Album})");
+ return iTunesResult;
+ }
+ }
+
+ // 3. iTunesで見つからなかった場合、LRCLIBの検索APIでフォールバック検索
+ foreach (var query in searchQueries.Take(3))
+ {
+ var lrcResult = await SearchLrcLibAsync(query, durationSeconds);
+ if (lrcResult != null)
+ {
+ LogManager.AddSuccess($"LRCLIB楽曲データベースと一致しました: 「{lrcResult.Artist} - {lrcResult.Title}」 (アルバム: {lrcResult.Album})");
+ return lrcResult;
+ }
+ }
+
+ return null;
+ }
+
+ ///
+ /// 検索用のクエリリストを優先順位順に組み立てる
+ ///
+ private List BuildSearchQueries(string rawVideoTitle, string uploader, string parsedArtist, string parsedTitle)
+ {
+ var list = new List();
+
+ // クリーンアップされたアップローダー名(- Topic 等を除去)
+ var cleanUploader = CmnUtil.CleanChannelName(uploader);
+
+ // A. パースされた "Artist Title" または "Title Artist"
+ if (!string.IsNullOrWhiteSpace(parsedArtist) && !string.IsNullOrWhiteSpace(parsedTitle) &&
+ parsedArtist != "Unknown" && parsedTitle != "Unknown")
+ {
+ list.Add($"{parsedArtist} {parsedTitle}");
+ list.Add($"{parsedTitle} {parsedArtist}");
+ }
+
+ // B. チャンネル名 + パースされた曲名
+ if (!string.IsNullOrWhiteSpace(cleanUploader) && !string.IsNullOrWhiteSpace(parsedTitle) &&
+ cleanUploader != parsedArtist && parsedTitle != "Unknown")
+ {
+ list.Add($"{cleanUploader} {parsedTitle}");
+ }
+
+ // C. カッコ等で囲まれたタイトル部分の抽出(「...」や『...』)
+ var bracketMatch = Regex.Match(rawVideoTitle, @"[「『""]([^「『""」』]+)[」』""]");
+ if (bracketMatch.Success)
+ {
+ var insideTitle = bracketMatch.Groups[1].Value.Trim();
+ if (!string.IsNullOrWhiteSpace(cleanUploader))
+ {
+ list.Add($"{cleanUploader} {insideTitle}");
+ }
+ list.Add(insideTitle);
+ }
+
+ // D. 装飾記号を除去した動画タイトル全体
+ var cleanedTitle = CmnUtil.CleanVideoTitle(rawVideoTitle);
+ if (!string.IsNullOrWhiteSpace(cleanedTitle))
+ {
+ list.Add(cleanedTitle);
+ }
+
+ // 重複排除
+ return list.Where(q => !string.IsNullOrWhiteSpace(q))
+ .Distinct(StringComparer.OrdinalIgnoreCase)
+ .ToList();
+ }
+
+ ///
+ /// iTunes Search API を呼び出して最適な曲を判定
+ ///
+ private async Task SearchITunesAsync(
+ string query,
+ string expectedArtist,
+ string expectedTitle,
+ double? expectedDuration)
+ {
+ try
+ {
+ var url = $"https://itunes.apple.com/search?term={Uri.EscapeDataString(query)}&country=jp&entity=song&limit=8";
+ using var request = new HttpRequestMessage(HttpMethod.Get, url);
+ request.Headers.UserAgent.ParseAdd(CmnDefine.UserAgent);
+
+ var response = await _httpClient.SendAsync(request);
+ if (!response.IsSuccessStatusCode) return null;
+
+ var json = await response.Content.ReadAsStringAsync();
+ var searchResponse = JsonSerializer.Deserialize(json);
+ if (searchResponse?.Results == null || searchResponse.Results.Count == 0) return null;
+
+ // 検索結果から最も一致度の高い曲をスコアリングして選出
+ ITunesSongItem? bestMatch = null;
+ int highestScore = -1;
+
+ foreach (var item in searchResponse.Results)
+ {
+ if (string.IsNullOrWhiteSpace(item.TrackName) || string.IsNullOrWhiteSpace(item.ArtistName))
+ continue;
+
+ var score = CalculateMatchScore(item, query, expectedArtist, expectedTitle, expectedDuration);
+ if (score > highestScore && score >= 30) // 最低限の適合閾値
+ {
+ highestScore = score;
+ bestMatch = item;
+ }
+ }
+
+ if (bestMatch != null)
+ {
+ uint? year = null;
+ if (!string.IsNullOrWhiteSpace(bestMatch.ReleaseDate) && bestMatch.ReleaseDate.Length >= 4)
+ {
+ if (uint.TryParse(bestMatch.ReleaseDate.Substring(0, 4), out var y)) year = y;
+ }
+
+ // 100x100 のサムネイルURLを高画質 (1000x1000) に置換
+ var artworkUrl = bestMatch.ArtworkUrl100;
+ if (!string.IsNullOrWhiteSpace(artworkUrl) && artworkUrl.Contains("100x100bb.jpg"))
+ {
+ artworkUrl = artworkUrl.Replace("100x100bb.jpg", "1000x1000bb.jpg");
+ }
+
+ var albumArtist = !string.IsNullOrWhiteSpace(bestMatch.CollectionArtistName)
+ ? bestMatch.CollectionArtistName
+ : bestMatch.ArtistName;
+
+ return new SongMetadataResult
+ {
+ Title = bestMatch.TrackName ?? expectedTitle,
+ Artist = bestMatch.ArtistName ?? expectedArtist,
+ Album = bestMatch.CollectionName ?? (!string.IsNullOrWhiteSpace(bestMatch.TrackName) ? bestMatch.TrackName : "Single"),
+ AlbumArtist = albumArtist ?? bestMatch.ArtistName ?? expectedArtist,
+ Year = year,
+ ArtworkUrl = artworkUrl,
+ DurationSeconds = bestMatch.TrackTimeMillis.HasValue ? bestMatch.TrackTimeMillis.Value / 1000.0 : null
+ };
+ }
+ }
+ catch (Exception ex)
+ {
+ LogManager.AddWarning($"iTunes検索中にエラー (query: {query}): {ex.Message}");
+ }
+
+ return null;
+ }
+
+ ///
+ /// LRCLIB API を用いたフォールバック検索
+ ///
+ private async Task SearchLrcLibAsync(string query, double? expectedDuration)
+ {
+ try
+ {
+ var url = $"{CmnDefine.LrcLibBaseUrl}/api/search?q={Uri.EscapeDataString(query)}";
+ using var request = new HttpRequestMessage(HttpMethod.Get, url);
+ request.Headers.UserAgent.ParseAdd(CmnDefine.UserAgent);
+
+ var response = await _httpClient.SendAsync(request);
+ if (!response.IsSuccessStatusCode) return null;
+
+ var json = await response.Content.ReadAsStringAsync();
+ var items = JsonSerializer.Deserialize(json);
+ if (items == null || items.Length == 0) return null;
+
+ // 再生時間が近い、または完全一致度が高いものを選択
+ Class.Lyrics.LrcLibResponse? best = null;
+ double minDiff = double.MaxValue;
+
+ foreach (var item in items)
+ {
+ if (string.IsNullOrWhiteSpace(item.TrackName) || string.IsNullOrWhiteSpace(item.ArtistName))
+ continue;
+
+ if (expectedDuration.HasValue && item.Duration.HasValue && item.Duration.Value > 0)
+ {
+ var diff = Math.Abs(item.Duration.Value - expectedDuration.Value);
+ if (diff < minDiff)
+ {
+ minDiff = diff;
+ best = item;
+ }
+ }
+ else
+ {
+ best = item;
+ break;
+ }
+ }
+
+ if (best != null && (!expectedDuration.HasValue || minDiff <= 10.0))
+ {
+ return new SongMetadataResult
+ {
+ Title = best.TrackName!,
+ Artist = best.ArtistName!,
+ Album = !string.IsNullOrWhiteSpace(best.AlbumName) ? best.AlbumName : best.TrackName!,
+ AlbumArtist = best.ArtistName!,
+ Year = null,
+ DurationSeconds = best.Duration
+ };
+ }
+ }
+ catch { }
+
+ return null;
+ }
+
+ ///
+ /// 検索候補の一致度スコアリング
+ ///
+ private int CalculateMatchScore(
+ ITunesSongItem item,
+ string query,
+ string expectedArtist,
+ string expectedTitle,
+ double? expectedDuration)
+ {
+ int score = 0;
+ var tName = item.TrackName ?? "";
+ var aName = item.ArtistName ?? "";
+
+ // 曲名の一致判定
+ if (!string.IsNullOrWhiteSpace(expectedTitle))
+ {
+ if (string.Equals(tName, expectedTitle, StringComparison.OrdinalIgnoreCase)) score += 50;
+ else if (tName.Contains(expectedTitle, StringComparison.OrdinalIgnoreCase) ||
+ expectedTitle.Contains(tName, StringComparison.OrdinalIgnoreCase)) score += 30;
+ }
+
+ // アーティスト名の一致判定
+ if (!string.IsNullOrWhiteSpace(expectedArtist))
+ {
+ if (string.Equals(aName, expectedArtist, StringComparison.OrdinalIgnoreCase)) score += 50;
+ else if (aName.Contains(expectedArtist, StringComparison.OrdinalIgnoreCase) ||
+ expectedArtist.Contains(aName, StringComparison.OrdinalIgnoreCase)) score += 30;
+ }
+
+ // クエリ全体との含有判定
+ if (query.Contains(tName, StringComparison.OrdinalIgnoreCase)) score += 20;
+ if (query.Contains(aName, StringComparison.OrdinalIgnoreCase)) score += 20;
+
+ // 再生時間の近似判定(±6秒以内なら高スコア)
+ if (expectedDuration.HasValue && item.TrackTimeMillis.HasValue)
+ {
+ var itemDurSec = item.TrackTimeMillis.Value / 1000.0;
+ var diff = Math.Abs(itemDurSec - expectedDuration.Value);
+ if (diff <= 3.0) score += 30;
+ else if (diff <= 6.0) score += 15;
+ else if (diff > 30.0) score -= 20; // 30秒以上乖離している場合は減点
+ }
+
+ return score;
+ }
+
+ ///
+ /// カバー画像URLから画像をダウンロードして一時ファイルに保存する
+ ///
+ public async Task DownloadArtworkAsync(string artworkUrl, string destFilePath)
+ {
+ if (string.IsNullOrWhiteSpace(artworkUrl)) return null;
+
+ try
+ {
+ using var request = new HttpRequestMessage(HttpMethod.Get, artworkUrl);
+ request.Headers.UserAgent.ParseAdd(CmnDefine.UserAgent);
+
+ var response = await _httpClient.SendAsync(request);
+ if (response.IsSuccessStatusCode)
+ {
+ var bytes = await response.Content.ReadAsByteArrayAsync();
+ await File.WriteAllBytesAsync(destFilePath, bytes);
+ return destFilePath;
+ }
+ }
+ catch (Exception ex)
+ {
+ LogManager.AddWarning($"カバー画像ダウンロードに失敗しました ({artworkUrl}): {ex.Message}");
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/MusicDownloader/MusicDownloader.csproj b/MusicDownloader/MusicDownloader.csproj
index 7838113..9b67175 100644
--- a/MusicDownloader/MusicDownloader.csproj
+++ b/MusicDownloader/MusicDownloader.csproj
@@ -27,6 +27,8 @@
+
+
diff --git a/MusicDownloader/Program.cs b/MusicDownloader/Program.cs
index 3cbb10c..8b211a6 100644
--- a/MusicDownloader/Program.cs
+++ b/MusicDownloader/Program.cs
@@ -8,6 +8,7 @@ using Microsoft.Extensions.DependencyInjection;
using MusicDownloader.Class;
using MusicDownloader.Class.Downloader;
using MusicDownloader.Class.Lyrics;
+using MusicDownloader.Class.Metadata;
// =========================================================================
// 【設定】ダウンロード対象のYouTubeプレイリストURLリスト
@@ -22,12 +23,15 @@ List defaultPlaylistUrls = new()
"https://www.youtube.com/playlist?list=PLcCVx7FV8UxriKA5suDcZeBoyuK7DFjck"
};
-// プレイリストの定期差分チェックを行うかどうか(true: 定期ポーリング、false: 1回完了後に待機/終了)
-bool isPeriodicCheck = false;
-TimeSpan checkInterval = TimeSpan.FromMinutes(60);
+// プレイリストの定期差分チェック常駐設定(デフォルトで常駐・2時間間隔)
+bool isPeriodicCheck = true;
+var intervalHoursStr = Environment.GetEnvironmentVariable("CHECK_INTERVAL_HOURS");
+var checkInterval = (double.TryParse(intervalHoursStr, out var h) && h > 0)
+ ? TimeSpan.FromHours(h)
+ : TimeSpan.FromHours(2);
// =========================================================================
-// 未処理例外ハンドリング (rss-generator 同様)
+// 未処理例外ハンドリング
// =========================================================================
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
{
@@ -61,14 +65,20 @@ services.AddSingleton(sp =>
var factory = sp.GetRequiredService();
return new LrcLibClient(factory.CreateClient("webClient"));
});
+services.AddSingleton(sp =>
+{
+ var factory = sp.GetRequiredService();
+ return new MusicMetadataClient(factory.CreateClient("webClient"));
+});
services.AddSingleton();
var serviceProvider = services.BuildServiceProvider();
var httpClientFactory = serviceProvider.GetRequiredService();
var lyricsManager = serviceProvider.GetRequiredService();
+var metadataClient = serviceProvider.GetRequiredService();
LogManager.AddLog($"==================================================");
-LogManager.AddLog($" MusicDownloader (Poweramp Optimized) 起動");
+LogManager.AddLog($" MusicDownloader (高音質・正確タグ・常駐版) 起動");
LogManager.AddLog($"==================================================");
// 出力先ディレクトリの決定
@@ -80,7 +90,7 @@ using var initClient = httpClientFactory.CreateClient("webClient");
var ytDlpPath = await DependencyManager.EnsureYtDlpAsync(initClient);
LogManager.AddLog($"使用 yt-dlp パス: {ytDlpPath}");
-var downloader = new YoutubeDownloader(ytDlpPath, lyricsManager);
+var downloader = new YoutubeDownloader(ytDlpPath, lyricsManager, metadataClient);
// =========================================================================
// ダウンロード対象プレイリストの解決
@@ -147,19 +157,24 @@ List ResolveTargetPlaylists(string baseDir)
}
// =========================================================================
-// ダウンロード処理ループ
+// ダウンロード処理ループ(①曲の取得 ➔ ②2時間待機 ➔ ③①へ戻る)
// =========================================================================
+int loopCount = 0;
+
while (true)
{
+ loopCount++;
var targetPlaylists = ResolveTargetPlaylists(outputDir);
- LogManager.AddLog($"対象プレイリスト総数: {targetPlaylists.Count} 件");
+ LogManager.AddLog($"================================================================================");
+ LogManager.AddLog($"[第 {loopCount} 回実行] 対象プレイリスト総数: {targetPlaylists.Count} 件のチェックを開始します");
+ LogManager.AddLog($"================================================================================");
for (int p = 0; p < targetPlaylists.Count; p++)
{
var playlistUrl = targetPlaylists[p];
- LogManager.AddLog($"================================================================================");
+ LogManager.AddLog($"--------------------------------------------------------------------------------");
LogManager.AddLog($"[プレイリスト {p + 1}/{targetPlaylists.Count}] 処理開始: {playlistUrl}");
- LogManager.AddLog($"================================================================================");
+ LogManager.AddLog($"--------------------------------------------------------------------------------");
try
{
@@ -182,6 +197,10 @@ while (true)
}
var nextRunTime = DateTime.Now.Add(checkInterval);
- LogManager.AddLog($"次回チェック予定: {nextRunTime:yyyy-MM-dd HH:mm:ss} ({checkInterval.TotalMinutes}分後)");
+ LogManager.AddSuccess($"================================================================================");
+ LogManager.AddSuccess($"全プレイリストのチェックが完了しました。次回実行まで {checkInterval.TotalHours:0.#} 時間待機します。");
+ LogManager.AddSuccess($"次回実行予定: {nextRunTime:yyyy-MM-dd HH:mm:ss}");
+ LogManager.AddSuccess($"================================================================================");
+
await Task.Delay(checkInterval);
}
diff --git a/MusicDownloader/obj/Debug/net10.0/MusicDownloader.AssemblyInfo.cs b/MusicDownloader/obj/Debug/net10.0/MusicDownloader.AssemblyInfo.cs
index 0ffacaf..40aae3e 100644
--- a/MusicDownloader/obj/Debug/net10.0/MusicDownloader.AssemblyInfo.cs
+++ b/MusicDownloader/obj/Debug/net10.0/MusicDownloader.AssemblyInfo.cs
@@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("MusicDownloader")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
-[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+be6183f05e9d9fbda85b7d3b7e659fc9b11a1bc1")]
+[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c0fdf1708a8b2c265224253be801c8f0d7fc3b3e")]
[assembly: System.Reflection.AssemblyProductAttribute("MusicDownloader")]
[assembly: System.Reflection.AssemblyTitleAttribute("MusicDownloader")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
diff --git a/MusicDownloader/obj/Debug/net10.0/MusicDownloader.GeneratedMSBuildEditorConfig.editorconfig b/MusicDownloader/obj/Debug/net10.0/MusicDownloader.GeneratedMSBuildEditorConfig.editorconfig
index f7d579e..3856aaa 100644
--- a/MusicDownloader/obj/Debug/net10.0/MusicDownloader.GeneratedMSBuildEditorConfig.editorconfig
+++ b/MusicDownloader/obj/Debug/net10.0/MusicDownloader.GeneratedMSBuildEditorConfig.editorconfig
@@ -11,7 +11,7 @@ build_property.EnforceExtendedAnalyzerRules =
build_property.EntryPointFilePath =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = MusicDownloader
-build_property.ProjectDir = c:\VS2026\MusicDownloader\MusicDownloader\
+build_property.ProjectDir = C:\VS2026\MusicDownloader\MusicDownloader\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.EffectiveAnalysisLevelStyle = 10.0
diff --git a/MusicDownloader/obj/MusicDownloader.csproj.nuget.dgspec.json b/MusicDownloader/obj/MusicDownloader.csproj.nuget.dgspec.json
index 8fd5f36..437b812 100644
--- a/MusicDownloader/obj/MusicDownloader.csproj.nuget.dgspec.json
+++ b/MusicDownloader/obj/MusicDownloader.csproj.nuget.dgspec.json
@@ -1,17 +1,17 @@
{
"format": 1,
"restore": {
- "c:\\VS2026\\MusicDownloader\\MusicDownloader\\MusicDownloader.csproj": {}
+ "C:\\VS2026\\MusicDownloader\\MusicDownloader\\MusicDownloader.csproj": {}
},
"projects": {
- "c:\\VS2026\\MusicDownloader\\MusicDownloader\\MusicDownloader.csproj": {
+ "C:\\VS2026\\MusicDownloader\\MusicDownloader\\MusicDownloader.csproj": {
"version": "1.0.0",
"restore": {
- "projectUniqueName": "c:\\VS2026\\MusicDownloader\\MusicDownloader\\MusicDownloader.csproj",
+ "projectUniqueName": "C:\\VS2026\\MusicDownloader\\MusicDownloader\\MusicDownloader.csproj",
"projectName": "MusicDownloader",
- "projectPath": "c:\\VS2026\\MusicDownloader\\MusicDownloader\\MusicDownloader.csproj",
+ "projectPath": "C:\\VS2026\\MusicDownloader\\MusicDownloader\\MusicDownloader.csproj",
"packagesPath": "C:\\Users\\uduki\\.nuget\\packages\\",
- "outputPath": "c:\\VS2026\\MusicDownloader\\MusicDownloader\\obj\\",
+ "outputPath": "C:\\VS2026\\MusicDownloader\\MusicDownloader\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages",
@@ -86,7 +86,7 @@
"privateAssets": "all"
}
},
- "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\10.0.400/PortableRuntimeIdentifierGraph.json",
+ "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\10.0.401/PortableRuntimeIdentifierGraph.json",
"packagesToPrune": {
"Microsoft.CSharp": "(,4.7.32767]",
"Microsoft.VisualBasic": "(,10.4.32767]",
diff --git a/MusicDownloader/obj/Release/net10.0/MusicDownloader.AssemblyInfo.cs b/MusicDownloader/obj/Release/net10.0/MusicDownloader.AssemblyInfo.cs
index 55ed35c..8829744 100644
--- a/MusicDownloader/obj/Release/net10.0/MusicDownloader.AssemblyInfo.cs
+++ b/MusicDownloader/obj/Release/net10.0/MusicDownloader.AssemblyInfo.cs
@@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("MusicDownloader")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
-[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+be6183f05e9d9fbda85b7d3b7e659fc9b11a1bc1")]
+[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c0fdf1708a8b2c265224253be801c8f0d7fc3b3e")]
[assembly: System.Reflection.AssemblyProductAttribute("MusicDownloader")]
[assembly: System.Reflection.AssemblyTitleAttribute("MusicDownloader")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
diff --git a/MusicDownloader/obj/Release/net10.0/MusicDownloader.GeneratedMSBuildEditorConfig.editorconfig b/MusicDownloader/obj/Release/net10.0/MusicDownloader.GeneratedMSBuildEditorConfig.editorconfig
index f7d579e..3856aaa 100644
--- a/MusicDownloader/obj/Release/net10.0/MusicDownloader.GeneratedMSBuildEditorConfig.editorconfig
+++ b/MusicDownloader/obj/Release/net10.0/MusicDownloader.GeneratedMSBuildEditorConfig.editorconfig
@@ -11,7 +11,7 @@ build_property.EnforceExtendedAnalyzerRules =
build_property.EntryPointFilePath =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = MusicDownloader
-build_property.ProjectDir = c:\VS2026\MusicDownloader\MusicDownloader\
+build_property.ProjectDir = C:\VS2026\MusicDownloader\MusicDownloader\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.EffectiveAnalysisLevelStyle = 10.0
diff --git a/MusicDownloader/obj/Release/net10.0/PublishOutputs.f0d91814d5.txt b/MusicDownloader/obj/Release/net10.0/PublishOutputs.f0d91814d5.txt
new file mode 100644
index 0000000..d1cf978
--- /dev/null
+++ b/MusicDownloader/obj/Release/net10.0/PublishOutputs.f0d91814d5.txt
@@ -0,0 +1,20 @@
+C:\VS2026\MusicDownloader\MusicDownloader\bin\Release\net10.0\publish\MusicDownloader.exe
+C:\VS2026\MusicDownloader\MusicDownloader\bin\Release\net10.0\publish\MusicDownloader.dll
+C:\VS2026\MusicDownloader\MusicDownloader\bin\Release\net10.0\publish\MusicDownloader.deps.json
+C:\VS2026\MusicDownloader\MusicDownloader\bin\Release\net10.0\publish\MusicDownloader.runtimeconfig.json
+C:\VS2026\MusicDownloader\MusicDownloader\bin\Release\net10.0\publish\MusicDownloader.pdb
+C:\VS2026\MusicDownloader\MusicDownloader\bin\Release\net10.0\publish\CliWrap.dll
+C:\VS2026\MusicDownloader\MusicDownloader\bin\Release\net10.0\publish\Microsoft.Extensions.Configuration.dll
+C:\VS2026\MusicDownloader\MusicDownloader\bin\Release\net10.0\publish\Microsoft.Extensions.Configuration.Abstractions.dll
+C:\VS2026\MusicDownloader\MusicDownloader\bin\Release\net10.0\publish\Microsoft.Extensions.Configuration.Binder.dll
+C:\VS2026\MusicDownloader\MusicDownloader\bin\Release\net10.0\publish\Microsoft.Extensions.DependencyInjection.dll
+C:\VS2026\MusicDownloader\MusicDownloader\bin\Release\net10.0\publish\Microsoft.Extensions.DependencyInjection.Abstractions.dll
+C:\VS2026\MusicDownloader\MusicDownloader\bin\Release\net10.0\publish\Microsoft.Extensions.Diagnostics.dll
+C:\VS2026\MusicDownloader\MusicDownloader\bin\Release\net10.0\publish\Microsoft.Extensions.Diagnostics.Abstractions.dll
+C:\VS2026\MusicDownloader\MusicDownloader\bin\Release\net10.0\publish\Microsoft.Extensions.Http.dll
+C:\VS2026\MusicDownloader\MusicDownloader\bin\Release\net10.0\publish\Microsoft.Extensions.Logging.dll
+C:\VS2026\MusicDownloader\MusicDownloader\bin\Release\net10.0\publish\Microsoft.Extensions.Logging.Abstractions.dll
+C:\VS2026\MusicDownloader\MusicDownloader\bin\Release\net10.0\publish\Microsoft.Extensions.Options.dll
+C:\VS2026\MusicDownloader\MusicDownloader\bin\Release\net10.0\publish\Microsoft.Extensions.Options.ConfigurationExtensions.dll
+C:\VS2026\MusicDownloader\MusicDownloader\bin\Release\net10.0\publish\Microsoft.Extensions.Primitives.dll
+C:\VS2026\MusicDownloader\MusicDownloader\bin\Release\net10.0\publish\TagLibSharp.dll
diff --git a/MusicDownloader/obj/project.assets.json b/MusicDownloader/obj/project.assets.json
index e063caa..ae0bde5 100644
--- a/MusicDownloader/obj/project.assets.json
+++ b/MusicDownloader/obj/project.assets.json
@@ -797,11 +797,11 @@
"project": {
"version": "1.0.0",
"restore": {
- "projectUniqueName": "c:\\VS2026\\MusicDownloader\\MusicDownloader\\MusicDownloader.csproj",
+ "projectUniqueName": "C:\\VS2026\\MusicDownloader\\MusicDownloader\\MusicDownloader.csproj",
"projectName": "MusicDownloader",
- "projectPath": "c:\\VS2026\\MusicDownloader\\MusicDownloader\\MusicDownloader.csproj",
+ "projectPath": "C:\\VS2026\\MusicDownloader\\MusicDownloader\\MusicDownloader.csproj",
"packagesPath": "C:\\Users\\uduki\\.nuget\\packages\\",
- "outputPath": "c:\\VS2026\\MusicDownloader\\MusicDownloader\\obj\\",
+ "outputPath": "C:\\VS2026\\MusicDownloader\\MusicDownloader\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages",
@@ -876,7 +876,7 @@
"privateAssets": "all"
}
},
- "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\10.0.400/PortableRuntimeIdentifierGraph.json",
+ "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\10.0.401/PortableRuntimeIdentifierGraph.json",
"packagesToPrune": {
"Microsoft.CSharp": "(,4.7.32767]",
"Microsoft.VisualBasic": "(,10.4.32767]",
diff --git a/compose.yaml b/compose.yaml
index 03b838f..2c07f51 100644
--- a/compose.yaml
+++ b/compose.yaml
@@ -3,19 +3,21 @@ services:
build: .
image: local-musicdownloader:latest
container_name: MusicDownloader
- # 完了後に自動停止する場合は "no"、定期チェック常駐させる場合は "unless-stopped"
- restart: "no"
- mem_limit: 512m
- memswap_limit: 512m
+ # 完了後も2時間待機ループで常駐させるため unless-stopped
+ restart: unless-stopped
+ mem_limit: 768m
+ memswap_limit: 768m
deploy:
resources:
limits:
- memory: 512M
+ memory: 768M
environment:
- TZ=Asia/Tokyo
# .NET GC設定: Workstation GC強制、ヒープ制限50%で省メモリ化
- DOTNET_gcServer=0
- DOTNET_GCHeapHardLimitPercent=50
+ # 定期チェック間隔(時間単位、デフォルト2時間)
+ - CHECK_INTERVAL_HOURS=2
# プレイリストURLをコンテナ側から上書きしたい場合に指定
# - PLAYLIST_URL=https://www.youtube.com/playlist?list=...
volumes: