feat: implement YouTube RSS feed generation with HTML parsing and data model support

This commit is contained in:
armonica committed 2026-09-02 11:28:16 +09:00
1 parent fe5e3335af
commit 590f1874b3
5 files changed
+475 -93

No files matched your search

+162 -24
View File
@@ -13,37 +13,175 @@ public static class YouTubeConfig
/// </summary> /// </summary>
public static readonly List<YouTubeChannelTarget> Channels = new() public static readonly List<YouTubeChannelTarget> Channels = new()
{ {
new YouTubeChannelTarget // === ゲームカテゴリ ===
{ new YouTubeChannelTarget { IdOrHandle = "UC4jVPBw6dP3mXCGJvRi3Xbw", Name = "0m0ti channel", Category = "ゲーム" },
IdOrHandle = "@ShirakamiFubuki", new YouTubeChannelTarget { IdOrHandle = "UCbNycyGQrscpF1TD9xJ8Gig", Name = "78 moco", Category = "ゲーム" },
Name = "白上フブキ", new YouTubeChannelTarget { IdOrHandle = "UCLezUXWjiJNxKqmAj6y-6FQ", Name = "asdfgame", Category = "ゲーム" },
FilePrefix = "shirakami_fubuki" new YouTubeChannelTarget { IdOrHandle = "UCpjv8V_jiIO9SdXfqp3lUDA", Name = "Bell's Workshop 2号店", Category = "ゲーム" },
}, new YouTubeChannelTarget { IdOrHandle = "UC0VoI57B2_63MErt_1QBpxA", Name = "EXAM", Category = "ゲーム" },
// 必要に応じてチャンネルを追加・編集してください。 new YouTubeChannelTarget { IdOrHandle = "UCO9s2_k1KMrGFU9SdpybE3Q", Name = "Fields Food", Category = "ゲーム" },
// 例: new YouTubeChannelTarget { IdOrHandle = "UCMFmbf-iDB87ScULtLIyUOQ", Name = "kazbye", Category = "ゲーム" },
// new YouTubeChannelTarget new YouTubeChannelTarget { IdOrHandle = "UChFlf5xHIVXCWCPz55Poh6w", Name = "Mine-Tech / MOD解説と日本語化", Category = "ゲーム" },
// { new YouTubeChannelTarget { IdOrHandle = "UCThE793GI6tJd6pXNahQVag", Name = "Nano", Category = "ゲーム" },
// IdOrHandle = "UCdn5BQ06XqgXoAxIhbqw5Rg", new YouTubeChannelTarget { IdOrHandle = "UCIAi_enV1mYGkKnhQtUMSIQ", Name = "SIANちゃんねる", Category = "ゲーム" },
// Name = "白上フブキ", new YouTubeChannelTarget { IdOrHandle = "UC-QiYHZEVe7u3lpuwUYHE4g", Name = "• みかづきch", Category = "ゲーム" },
// FilePrefix = "fubuki_ch" new YouTubeChannelTarget { IdOrHandle = "UC_S6Bi_Q11cPxe9ZjSzeU9Q", Name = "あそぶよ【長縄まりあ】", Category = "ゲーム" },
// }, new YouTubeChannelTarget { IdOrHandle = "UCqp3XrY7wux-E3kl4A4ZmQQ", Name = "いわしのお薬解説チャンネル", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCcLWyYVS3ysazvYjN7pKXuw", Name = "いわしのゲーム実況チャンネル", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UC3ZLsHo4JBXFU0-S2ccLWxg", Name = "うし将軍CH", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCVQPydGugrmZqatY4jKcgtQ", Name = "うたたねヒツジ", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UC-x3NpR9xlDOT_7BS6heSGw", Name = "おっP / のめ", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCQJaE9hvHI3muexZWj3LKXQ", Name = "おーちゃんねる", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCmUZv71jJwIqer1aTEbJFmg", Name = "さくよう", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCt30jJgChL8qeT9VPadidSw", Name = "しぐれうい", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCIr_W70tfZB8_Qca6F-gVSQ", Name = "しまねげーむず", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCejsdItB2yHYzTcc_GRf-cA", Name = "しゃちくのぐらぶらー", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCHkgbFkEddyLE5uQMCem_aw", Name = "でいすいのゲームちゃんねる/DeisuiGames", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCYs1ZWlXG31QyY1gcFfMuHA", Name = "なりす@尾張なな", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCFxo023wmsr4Jp43YihCoRQ", Name = "にと", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCTW2tw0Mhho72MojB1L48IQ", Name = "のばまんゲームス", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCbNeUGA_MAKxzaF_YfG9hjQ", Name = "ほしみやch", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCZFHPeF9g1R5E_CzE1KpfUg", Name = "ほわいとさんの音ゲー部屋", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UC8dBPlnKodOG7eoPa9RuUFg", Name = "ましゅるむ", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCFBSXqhTCTQp7zfXO-FhA6A", Name = "みざちゃんねる", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCXuSdahMWaRnmbsxS_ETOiA", Name = "ゆっくりひつじチャンネル", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCbXWcfCv-osdKOMpYh6TgxA", Name = "れど", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCY5M1FeR1BQNsnumsJA1epA", Name = "れぷちん", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCeVxYzfdg2hJlwXsx3vcIfA", Name = "れもん", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UC08BWOux8OI84Zg5O8lzPLw", Name = "ろぉれわち", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCo1RH7pR_wdgY_9LKONxXvA", Name = "エナメル巻きで食べるサラダ", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCbC7w818ZosPu6OtXsrEnow", Name = "クワトロ【GBF】 quwatoro", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCfxC2jkCQn3SEMYYtprPQ4w", Name = "タコ丸 / 村人狂【マイクラ 小ネタ 検証 茶番】", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCmIxgPt36VRqcvu8cJRgl3g", Name = "ニグチャンネル", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UChn5TjkeEqd-JxzizMVSkOw", Name = "ハヤトの野望", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UC3UXwChdzkI6AYyl6Awz5FQ", Name = "バリン3g", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCv_jreWfYg70AcUQHrdJwNQ", Name = "フルコンチャンネル", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCCmP2lDoK06iHtktje43Jag", Name = "ブルアカパンツ小隊", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UC1vOvxlZofZQog12GjpgMMQ", Name = "ペンタ", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCzXjPL7zo0bxhOYDxLJ9YEg", Name = "ポッキー", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCGsQ2MkZvw5AUZNuL-JiP2A", Name = "マイクラMod解説屋", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCOTNIvcW4Ub528gizWakm3Q", Name = "メカユウ", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCojRF-b4D0R5JFZYa9iJfKw", Name = "リターンリターンリターン", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCs_0n9y_qw6fAniS4mQ7q8w", Name = "凪尾:games", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCLZb4xWiVcYqefZNIFc7K1A", Name = "崩壊スターレイル解説ちゃん@Hoshica", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCQ5YkZwjrkHNu93QVJOxDKw", Name = "田楽", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UC5aEf6Vhsmm8L7A5AVpJIZg", Name = "田辺魅癒喜", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UC9WMsQHOevJPa7tAIRAri7g", Name = "草の人", Category = "ゲーム" },
new YouTubeChannelTarget { IdOrHandle = "UCOxeFwiz5SV5eKZffBsNvNg", Name = "風呂桶", Category = "ゲーム" },
// === その他カテゴリ ===
new YouTubeChannelTarget { IdOrHandle = "UC_iaJAt7aUR8QU8QFJHd7pw", Name = "自作PCニュースを毎週日曜夜に投稿! Aile Ch. エイル", Category = "その他" },
new YouTubeChannelTarget { IdOrHandle = "UCSHv8d_zagb752Gg-7qXsoQ", Name = "花のお掃除〜小川水道メンテナンス〜", Category = "その他" },
new YouTubeChannelTarget { IdOrHandle = "UCmnW84E3W8CvCjY_bC3XPjQ", Name = "花の記録", Category = "その他" },
new YouTubeChannelTarget { IdOrHandle = "UCzikSGB8gvVfUkcZiks8IXg", Name = "クソガキサラリーマン", Category = "その他" },
new YouTubeChannelTarget { IdOrHandle = "UCds31pB1MwOsyUq146nDBXw", Name = "ゆっくりダークな裏知識", Category = "その他" },
new YouTubeChannelTarget { IdOrHandle = "UCUHg7zFbbjSHvW1heBOqnxw", Name = "ゆっくりkm", Category = "その他" },
new YouTubeChannelTarget { IdOrHandle = "UCcT5a1J7XJW7CLYI2RKl4pw", Name = "ゆっくりするところ", Category = "その他" },
new YouTubeChannelTarget { IdOrHandle = "UCpj29wrH9rPRiBAZQSHjgCg", Name = "ためにならない!!", Category = "その他" },
new YouTubeChannelTarget { IdOrHandle = "UCTftnkJ6Mkyz5wdX2jozsmw", Name = "チー牛速報", Category = "その他" },
// === 野球カテゴリ ===
new YouTubeChannelTarget { IdOrHandle = "UC5KWnEUsanq8wkOuFLqY4Eg", Name = "2ch野球スレ魂", Category = "野球" },
new YouTubeChannelTarget { IdOrHandle = "UCQtDjKH7sVWzXmBjhmeQiQQ", Name = "DeNA反応ch【プロ野球】", Category = "野球" },
new YouTubeChannelTarget { IdOrHandle = "UC4h5sI5W1jSbXf_9ssVqSzQ", Name = "The Carp Watcher_日本の野球考察チャンネル", Category = "野球" },
new YouTubeChannelTarget { IdOrHandle = "UC8gouwCLu2K8lx7beIrleXw", Name = "こちら野球の反応集", Category = "野球" },
new YouTubeChannelTarget { IdOrHandle = "UCJgpTVEsD6r_vHJ5sIw9kYg", Name = "こちら野球の反応集 プロ野球 反応集", Category = "野球" },
new YouTubeChannelTarget { IdOrHandle = "UC9zWy8zm5S9QZvdqZlnYhMg", Name = "なんJパリーグ部", Category = "野球" },
new YouTubeChannelTarget { IdOrHandle = "UCQc0b9djO5K5Fa6ukbbKiwg", Name = "なーんJ【プロ野球まとめ】", Category = "野球" },
new YouTubeChannelTarget { IdOrHandle = "UC2YRjYml8bQH3CCESVwkOzA", Name = "ようこそ野球さん【2ch反応】【なんJ】", Category = "野球" },
new YouTubeChannelTarget { IdOrHandle = "UC_iPYESk3LQDdDJT9rJuJng", Name = "セリーグニュース【2ch 5ch なんj】", Category = "野球" },
new YouTubeChannelTarget { IdOrHandle = "UCEdm-j9MnboCjWZAye2J8gw", Name = "プロ野球まとめ【最新情報・反応集】なんJ【2ch・5ch】", Category = "野球" },
new YouTubeChannelTarget { IdOrHandle = "UCqAiME9UAn5aalImaR_L62Q", Name = "プロ野球スレ反応集チャンネル", Category = "野球" },
new YouTubeChannelTarget { IdOrHandle = "UCsZgbpIQu1TLMDmwSTriwBA", Name = "人生ゲッツー【パリーグ・セリーグ反応集】", Category = "野球" },
new YouTubeChannelTarget { IdOrHandle = "UC-InbUMe7DQcbVL4j-pCPsw", Name = "野村謙二郎のノムケンCHANNEL", Category = "野球" },
new YouTubeChannelTarget { IdOrHandle = "UCPdVfUhzFV9fjZ8ndwWLP-g", Name = "野球反応集SUPER", Category = "野球" },
new YouTubeChannelTarget { IdOrHandle = "UCeN20O5cpjAIqw9fRVbLlGw", Name = "野球情報まとめ", Category = "野球" },
new YouTubeChannelTarget { IdOrHandle = "UC9qqYgqTOBBW8rZhLmGm0yg", Name = "NEXTSTEP⚾︎BASEBALL (JAPAN)", Category = "野球" },
// === 音楽カテゴリ ===
new YouTubeChannelTarget { IdOrHandle = "UCdypzqq-d62AlNuQvN9NxMA", Name = "チュウニズム譜面保管所 VERSE", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCVa1ztcmGL2aM8DTJgCfO-Q", Name = "Akina 秋奈 YouTube", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCP7Gw_YZAuh4Yg2fcdcuumQ", Name = "ARASHI", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UChNkqst-cjAoIbXb-ukn_tQ", Name = "BE:FIRST Official", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCtmTQJC_hOJtY1MV2JUAmDA", Name = "Bucket Banquetビスたん", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCAtnYTUVSA7eOUOwr-W6Z9A", Name = "CrosSing", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCRh8owDtQAUKvRfwnagz84g", Name = "CS4W", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCVbTqPzmorYfPotO6IMelkA", Name = "DOLCE. / dolce_iwate Channel", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCCcBQ6v5TRGqP40JhlN10QQ", Name = "Eric-P (에맄)", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCV_RVr8NpbYv55r4ahi86Qw", Name = "HistoryAccurateDevelopers", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCihPtqLGoOBvzIMDOJjzb_g", Name = "kyaami", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCvDFVqslkZ4he3z3NmXu1sw", Name = "Laur", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCyIfeBaEBBXXiQ3aRid4X5Q", Name = "LEID", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCcvLSRIWJIAGFDyWtzkbiHA", Name = "marasy8", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCek7I7m1MtioLAKxKFzGQkg", Name = "Shirakawa niNo", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCDwhhbUNmTtc8GsLrX-VbUw", Name = "SHOW-YA【赤髪トランペッター】", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UC-NStn927rkPlj85972VfoA", Name = "tn-shi", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCmYH84UcJ6oVczKm0sY5aeg", Name = "tsukihaka george", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCPd0Z22gF43dUidPYEQO5-w", Name = "VESPERBELL", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCR61XV4ROXhkcfLO31hTGuw", Name = "「KING AMUSEMENT CREATIVE」公式チャンネル", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCzbj36R2CRdQs6Ve47h5_wQ", Name = "しゃみお - Shamisen player Shamio", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCWrTVYsrY3fG0t8VRZYzDuA", Name = "たけやん", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCiBjZw_TwasTODFH_fx8cSA", Name = "ただの蛍", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCfw1ozW-vUsNsgGuxV0VzYg", Name = "だんちょうてい", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCXcnRAydzstW5HehZYxtzzA", Name = "ふぃくしのん / phyxinon", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCsGN0F2iJg5j2YwIt7I_BOQ", Name = "やじゅぴあの -YazyuPiano- Channel", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCJc1WRHiPI4WVA3pY_d6Lmg", Name = "オサキハン / Osakihan", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCfyzrRchEuYWpbWnXNRwNLw", Name = "シアーミュージック", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCUc2MVjtdBHCs05pwtXg9QA", Name = "シアーミュージックライブ", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCYF-JXFbe4oYKbwsz73y2TQ", Name = "スティックのり", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UC--zuEfONeFXPvLqX0Kvbuw", Name = "松永依織 / IORI MATSUNAGA", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCQHCHIoeu0FRJTJNMG2_Ezw", Name = "藍月なくる / Aitsuki Nakuru", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UClqZm49qdCGaV96s2ZN9--Q", Name = "超銀河レコード", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCWF-3hyAv7TFw8mpS_wHLmw", Name = "音羽ララ (Otohane Lara) / シアーミュージックV", Category = "音楽" },
new YouTubeChannelTarget { IdOrHandle = "UCvNnyy0_KxpJegpv3ytVM5Q", Name = "魔王魂公式チャンネル【森田交一】", Category = "音楽" },
// === Apexカテゴリ ===
new YouTubeChannelTarget { IdOrHandle = "UCiUN3mkcZX4gSf74fhwEj5g", Name = "Civ:Aちゃんねーる", Category = "Apex" },
new YouTubeChannelTarget { IdOrHandle = "UCVdSdMNbPDlccE34MzKpg8g", Name = "TIE", Category = "Apex" },
new YouTubeChannelTarget { IdOrHandle = "UCY_qQE1SSMciTm6qG4pgkfg", Name = "TIE Ru", Category = "Apex" },
new YouTubeChannelTarget { IdOrHandle = "UCo8XDFok-CJIVWE7MxQF0Fw", Name = "TIE_Gian", Category = "Apex" },
new YouTubeChannelTarget { IdOrHandle = "UCENixCNx4v78m-0e1WseRrg", Name = "あかめいん", Category = "Apex" },
// === 公式チャンネルカテゴリ ===
new YouTubeChannelTarget { IdOrHandle = "UC0v-pxTo1XamIDE-f__Ad0Q", Name = "(パーソル パ・リーグTV公式)PacificLeagueTV", Category = "公式" },
new YouTubeChannelTarget { IdOrHandle = "UCfWaYoWWSlY-K2TJU0UW-pQ", Name = "J SPORTS 野球【公式】", Category = "公式" },
new YouTubeChannelTarget { IdOrHandle = "UCkH3CcMfqww9RsZvPRPkAJA", Name = "Nintendo 公式チャンネル", Category = "公式" },
new YouTubeChannelTarget { IdOrHandle = "UCT4FClZsDrg_b7OPmoLmhlQ", Name = "【カープ公認】金鯉チャンネル 広テレ", Category = "公式" },
new YouTubeChannelTarget { IdOrHandle = "UCg9YmSd9-AF2RRPNHsLjj2A", Name = "【公式】広島ホームテレビ", Category = "公式" },
new YouTubeChannelTarget { IdOrHandle = "UC41c53J_kGJk08kdN0xlVRA", Name = "【球団お墨付き】勝ちグセCarpチャンネル", Category = "公式" },
new YouTubeChannelTarget { IdOrHandle = "UCGtlcql20e1g3iCn6LrWLug", Name = "【球団認定】カープ全力応援チャンネル TSS", Category = "公式" },
new YouTubeChannelTarget { IdOrHandle = "UCwTk9STAIznJprH-jrzcqgw", Name = "あなたの理想不動産", Category = "公式" },
new YouTubeChannelTarget { IdOrHandle = "UCNsidkYpIAQ4QaufptQBPHQ", Name = "ウェザーニュース", Category = "公式" },
new YouTubeChannelTarget { IdOrHandle = "UCBV4S3kliBSKTFswcTEhC9w", Name = "グランブルーファンタジー公式チャンネル", Category = "公式" },
new YouTubeChannelTarget { IdOrHandle = "UCxppu_g5LuimLxVdxnqQXBw", Name = "スカパー!カープチャンネル", Category = "公式" },
new YouTubeChannelTarget { IdOrHandle = "UCvF8OEpJPsM-JWhTWzvX3fw", Name = "フジテレビドキュメンタリー", Category = "公式" },
new YouTubeChannelTarget { IdOrHandle = "UCmgf8DJrAXFnU7j3u0kklUQ", Name = "ブルーアーカイブ-Blue Archive-", Category = "公式" },
new YouTubeChannelTarget { IdOrHandle = "UCdMGYXL38w6htx6Yf9YJa-w", Name = "プロジェクトセカイ カラフルステージ! feat. 初音ミク", Category = "公式" },
new YouTubeChannelTarget { IdOrHandle = "UCrzCIt5o0X88G9bCdrdbv6g", Name = "崩壊:スターレイル", Category = "公式" },
new YouTubeChannelTarget { IdOrHandle = "UCyHdFYJyt4Ihwuscuk5ALJA", Name = "広テレ!NEWS", Category = "公式" },
new YouTubeChannelTarget { IdOrHandle = "UC0VGvOEN22JcprH7pZrCwiw", Name = "広島東洋カープ公式", Category = "公式" },
}; };
/// <summary>
/// チャンネルごとの個別XMLファイルを出力するかどうか(例: shirakami_fubuki_live.xml)
/// </summary>
public static bool ExportIndividualFeeds { get; set; } = true;
/// <summary>
/// 全チャンネルを統合したXMLファイルを出力するかどうか(all_live.xml, all_video.xml, all_shorts.xml)
/// </summary>
public static bool ExportMergedFeeds { get; set; } = true;
/// <summary> /// <summary>
/// 出力先のサブディレクトリ名(output/youtube/ 配下に出力されます) /// 出力先のサブディレクトリ名(output/youtube/ 配下に出力されます)
/// </summary> /// </summary>
public static string OutputSubDir { get; set; } = "youtube"; public static string OutputSubDir { get; set; } = "youtube";
/// <summary>
/// 統合ライブ配信フィードのファイル名
/// </summary>
public static string MergedLiveFileName { get; set; } = "live.xml";
/// <summary>
/// 統合動画フィードのファイル名
/// </summary>
public static string MergedVideoFileName { get; set; } = "video.xml";
/// <summary>
/// 統合ショート動画フィードのファイル名
/// </summary>
public static string MergedShortsFileName { get; set; } = "shorts.xml";
/// <summary> /// <summary>
/// 各フィードの最大保持件数 /// 各フィードの最大保持件数
/// </summary> /// </summary>
@@ -4,7 +4,9 @@ using System.Linq;
using System.Net; using System.Net;
using System.ServiceModel.Syndication; using System.ServiceModel.Syndication;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml.Linq;
namespace rss_generator.Class.RSS.YouTube; namespace rss_generator.Class.RSS.YouTube;
@@ -27,8 +29,12 @@ public static class YouTubeFeedManager
var allVideoItems = new List<YouTubeVideoItem>(); var allVideoItems = new List<YouTubeVideoItem>();
var allShortsItems = new List<YouTubeVideoItem>(); var allShortsItems = new List<YouTubeVideoItem>();
// YouTubeからのレート制限を防ぐため、同時並行数を安全な値(6)に制御
using var semaphore = new System.Threading.SemaphoreSlim(6);
var channelTasks = YouTubeConfig.Channels.Select(async channel => var channelTasks = YouTubeConfig.Channels.Select(async channel =>
{ {
await semaphore.WaitAsync();
try try
{ {
await ProcessChannelAsync(client, channel, allLiveItems, allVideoItems, allShortsItems); await ProcessChannelAsync(client, channel, allLiveItems, allVideoItems, allShortsItems);
@@ -37,16 +43,43 @@ public static class YouTubeFeedManager
{ {
LogManager.AddLog($"[エラー] チャンネル処理失敗 ({channel.Name ?? channel.IdOrHandle}): {ex.Message}"); LogManager.AddLog($"[エラー] チャンネル処理失敗 ({channel.Name ?? channel.IdOrHandle}): {ex.Message}");
} }
finally
{
semaphore.Release();
}
}); });
await Task.WhenAll(channelTasks); await Task.WhenAll(channelTasks);
// 全チャンネル統合フィードの出力 // 登録されたカテゴリ一覧を取得してカテゴリ別にフィードを出力
if (YouTubeConfig.ExportMergedFeeds) var categories = YouTubeConfig.Channels
.Select(c => string.IsNullOrWhiteSpace(c.Category) ? "その他" : c.Category.Trim())
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
foreach (var category in categories)
{ {
ExportMergedFeed(allLiveItems, YouTubeFeedType.Live, "all_live.xml", "YouTube Live (All Channels)"); try
ExportMergedFeed(allVideoItems, YouTubeFeedType.Video, "all_video.xml", "YouTube Videos (All Channels)"); {
ExportMergedFeed(allShortsItems, YouTubeFeedType.Shorts, "all_shorts.xml", "YouTube Shorts (All Channels)"); var catLive = allLiveItems.Where(i => string.Equals(i.Category, category, StringComparison.OrdinalIgnoreCase)).ToList();
var catVideo = allVideoItems.Where(i => string.Equals(i.Category, category, StringComparison.OrdinalIgnoreCase)).ToList();
var catShorts = allShortsItems.Where(i => string.Equals(i.Category, category, StringComparison.OrdinalIgnoreCase)).ToList();
string slug = GetCategoryFileSlug(category);
string liveFile = $"{slug}_live.xml";
string videoFile = $"{slug}_video.xml";
string shortsFile = $"{slug}_shorts.xml";
string catTitleSuffix = $" - {category}";
ExportMergedFeed(catLive, YouTubeFeedType.Live, liveFile, $"YouTube Live{catTitleSuffix}");
ExportMergedFeed(catVideo, YouTubeFeedType.Video, videoFile, $"YouTube Videos{catTitleSuffix}");
ExportMergedFeed(catShorts, YouTubeFeedType.Shorts, shortsFile, $"YouTube Shorts{catTitleSuffix}");
}
catch (Exception ex)
{
LogManager.AddLog($"[エラー] カテゴリ出力失敗 ({category}): {ex.Message}");
}
} }
LogManager.AddLog("[情報] YouTubeフィード生成が完了しました"); LogManager.AddLog("[情報] YouTubeフィード生成が完了しました");
@@ -67,27 +100,44 @@ public static class YouTubeFeedManager
List<YouTubeVideoItem> allLiveItems, List<YouTubeVideoItem> allLiveItems,
List<YouTubeVideoItem> allVideoItems, List<YouTubeVideoItem> allVideoItems,
List<YouTubeVideoItem> allShortsItems) List<YouTubeVideoItem> allShortsItems)
{
string channelDisplayName = channel.Name ?? channel.IdOrHandle;
try
{ {
// 3つのタブを並行取得 // 3つのタブを並行取得
var liveTask = FetchTabItemsAsync(client, channel, YouTubeFeedType.Live); var liveTask = FetchTabItemsAsync(client, channel, YouTubeFeedType.Live);
var videoTask = FetchTabItemsAsync(client, channel, YouTubeFeedType.Video); var videoTask = FetchTabItemsAsync(client, channel, YouTubeFeedType.Video);
var shortsTask = FetchTabItemsAsync(client, channel, YouTubeFeedType.Shorts); var shortsTask = FetchTabItemsAsync(client, channel, YouTubeFeedType.Shorts);
await Task.WhenAll(liveTask, videoTask, shortsTask); // チャンネルIDが判明している場合、公式Atomフィードから正確な公開日マップを並行取得
string channelId = ExtractChannelId(channel);
Task<Dictionary<string, DateTimeOffset>> officialDatesTask = !string.IsNullOrEmpty(channelId)
? FetchOfficialPublishedDatesAsync(client, channelId)
: Task.FromResult(new Dictionary<string, DateTimeOffset>(StringComparer.OrdinalIgnoreCase));
await Task.WhenAll(liveTask, videoTask, shortsTask, officialDatesTask);
var liveItems = await liveTask; var liveItems = await liveTask;
var videoItems = await videoTask; var videoItems = await videoTask;
var shortsItems = await shortsTask; var shortsItems = await shortsTask;
var officialDates = await officialDatesTask;
// 個別フィードの出力 // 公式フィードの日時(秒単位の正確な公開日)で補完・上書き
if (YouTubeConfig.ExportIndividualFeeds) if (officialDates.Count > 0)
{ {
string prefix = channel.GetSafeFilePrefix(); ApplyOfficialDates(liveItems, officialDates);
string channelTitle = channel.Name ?? channel.IdOrHandle; ApplyOfficialDates(videoItems, officialDates);
ApplyOfficialDates(shortsItems, officialDates);
}
ExportFeed(liveItems, channelTitle, $"{prefix}_live.xml", YouTubeFeedType.Live); // ショート動画で日付が取れなかったものの並び順推定(取得日時に固定されるのを防止)
ExportFeed(videoItems, channelTitle, $"{prefix}_video.xml", YouTubeFeedType.Video); AdjustShortsDates(shortsItems);
ExportFeed(shortsItems, channelTitle, $"{prefix}_shorts.xml", YouTubeFeedType.Shorts);
int totalCount = liveItems.Count + videoItems.Count + shortsItems.Count;
if (totalCount == 0)
{
LogManager.AddLog($"[警告] 取得アイテム0件 【{channelDisplayName}】 ({channel.IdOrHandle})");
} }
// 統合フィード用に蓄積 // 統合フィード用に蓄積
@@ -95,6 +145,12 @@ public static class YouTubeFeedManager
lock (allVideoItems) { allVideoItems.AddRange(videoItems); } lock (allVideoItems) { allVideoItems.AddRange(videoItems); }
lock (allShortsItems) { allShortsItems.AddRange(shortsItems); } lock (allShortsItems) { allShortsItems.AddRange(shortsItems); }
} }
catch (Exception ex)
{
// チャンネルごとのエラーを出力して処理を続行
LogManager.AddLog($"[エラー] チャンネル処理失敗 【{channelDisplayName}】 ({channel.IdOrHandle}): {ex.Message}");
}
}
/// <summary> /// <summary>
/// 指定されたタブ種別のHTMLを取得してパースします。 /// 指定されたタブ種別のHTMLを取得してパースします。
@@ -104,6 +160,7 @@ public static class YouTubeFeedManager
YouTubeChannelTarget channel, YouTubeChannelTarget channel,
YouTubeFeedType feedType) YouTubeFeedType feedType)
{ {
string channelDisplayName = channel.Name ?? channel.IdOrHandle;
string url = channel.GetTabUrl(feedType); string url = channel.GetTabUrl(feedType);
try try
@@ -115,7 +172,7 @@ public static class YouTubeFeedManager
using var response = await client.SendAsync(request); using var response = await client.SendAsync(request);
if (!response.IsSuccessStatusCode) if (!response.IsSuccessStatusCode)
{ {
LogManager.AddLog($"[警告] HTTPステータス異常 ({response.StatusCode}): {url}"); LogManager.AddLog($"[警告] タブ取得HTTPエラー 【{channelDisplayName}】({feedType}) [{(int)response.StatusCode} {response.StatusCode}]: {url}");
return new List<YouTubeVideoItem>(); return new List<YouTubeVideoItem>();
} }
@@ -127,38 +184,140 @@ public static class YouTubeFeedManager
} }
catch (Exception ex) catch (Exception ex)
{ {
LogManager.AddLog($"[エラー] タブ取得失敗 ({url}): {ex.Message}"); LogManager.AddLog($"[エラー] タブ取得失敗 【{channelDisplayName}】({feedType}): {ex.Message}");
return new List<YouTubeVideoItem>(); return new List<YouTubeVideoItem>();
} }
} }
/// <summary> /// <summary>
/// チャンネル個別フィードを出力します。 /// チャンネルID(UC...)を抽出します。
/// </summary> /// </summary>
private static void ExportFeed( private static string ExtractChannelId(YouTubeChannelTarget channel)
{
string target = channel.IdOrHandle ?? "";
if (target.StartsWith("UC", StringComparison.OrdinalIgnoreCase) && target.Length >= 24)
{
return target.Substring(0, 24);
}
var match = Regex.Match(target, @"UC[a-zA-Z0-9_-]{22}");
if (match.Success)
{
return match.Value;
}
return "";
}
/// <summary>
/// YouTube公式Atomフィード(通常動画・ショート用)から videoId -> publishedDate の辞書を取得します。
/// </summary>
private static async Task<Dictionary<string, DateTimeOffset>> FetchOfficialPublishedDatesAsync(
HttpClient client,
string channelId)
{
var result = new Dictionary<string, DateTimeOffset>(StringComparer.OrdinalIgnoreCase);
// 1. チャンネル直近フィード
string channelFeedUrl = $"https://www.youtube.com/feeds/videos.xml?channel_id={channelId}";
// 2. ショート用プレイリストフィード (UUSH + channelId[2..])
string shortsFeedUrl = channelId.Length >= 24
? $"https://www.youtube.com/feeds/videos.xml?playlist_id=UUSH{channelId.Substring(2)}"
: "";
var task1 = FetchAtomDatesAsync(client, channelFeedUrl);
var task2 = !string.IsNullOrEmpty(shortsFeedUrl)
? FetchAtomDatesAsync(client, shortsFeedUrl)
: Task.FromResult(new Dictionary<string, DateTimeOffset>());
await Task.WhenAll(task1, task2);
foreach (var kvp in await task1)
{
result[kvp.Key] = kvp.Value;
}
foreach (var kvp in await task2)
{
result[kvp.Key] = kvp.Value;
}
return result;
}
/// <summary>
/// 指定されたAtomフィードURLから videoId -> publishedDate を抽出します。
/// </summary>
private static async Task<Dictionary<string, DateTimeOffset>> FetchAtomDatesAsync(HttpClient client, string url)
{
var dict = new Dictionary<string, DateTimeOffset>(StringComparer.OrdinalIgnoreCase);
try
{
using var response = await client.GetAsync(url);
if (!response.IsSuccessStatusCode) return dict;
string xml = await response.Content.ReadAsStringAsync();
var doc = XDocument.Parse(xml);
XNamespace atom = "http://www.w3.org/2005/Atom";
XNamespace yt = "http://www.youtube.com/xml/schemas/2015";
foreach (var entry in doc.Descendants(atom + "entry"))
{
string videoId = entry.Element(yt + "videoId")?.Value ?? "";
string pubStr = entry.Element(atom + "published")?.Value ?? "";
if (!string.IsNullOrWhiteSpace(videoId) &&
DateTimeOffset.TryParse(pubStr, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out var pubDate))
{
dict[videoId] = pubDate;
}
}
}
catch
{
// Atomフィード取得失敗時は無視してHTML側の日時を使用
}
return dict;
}
/// <summary>
/// 公式フィードの日時をアイテムに反映します。
/// </summary>
private static void ApplyOfficialDates(
List<YouTubeVideoItem> items, List<YouTubeVideoItem> items,
string channelTitle, Dictionary<string, DateTimeOffset> officialDates)
string fileName,
YouTubeFeedType feedType)
{ {
string typeLabel = feedType switch foreach (var item in items)
{ {
YouTubeFeedType.Live => "ライブ配信", if (officialDates.TryGetValue(item.VideoId, out var pubDate))
YouTubeFeedType.Video => "動画", {
YouTubeFeedType.Shorts => "ショート動画", item.PublishedDate = pubDate;
_ => "フィード" }
}; }
}
var syndicationItems = items.Select(CreateSyndicationItem).ToList(); /// <summary>
/// ショート動画で公開日が未設定(現在日時のまま)のアイテムに対し、並び順に基づく過去日時の減算を適用します。
/// </summary>
private static void AdjustShortsDates(List<YouTubeVideoItem> shorts)
{
if (shorts == null || shorts.Count == 0) return;
var feed = new SyndicationFeed( // 公式日付が得られている最新アイテムの日時、または現在日時を基準にする
$"{channelTitle} - {typeLabel}", var now = DateTimeOffset.Now;
$"{channelTitle} の {typeLabel} RSSフィード", DateTimeOffset baseDate = shorts.FirstOrDefault(s => s.PublishedDate < now.AddMinutes(-5))?.PublishedDate ?? now.AddHours(-1);
new Uri(items.FirstOrDefault()?.ChannelUrl ?? "https://www.youtube.com"),
syndicationItems
);
CmnUtil.ExportXMLFile(fileName, feed, YouTubeConfig.OutputSubDir); for (int i = 0; i < shorts.Count; i++)
{
// 現在時刻(直近5分以内)のままのものは、順序に応じて過去日時に推定
if (shorts[i].PublishedDate >= now.AddMinutes(-5))
{
shorts[i].PublishedDate = baseDate.AddDays(-(i + 1));
}
else
{
baseDate = shorts[i].PublishedDate;
}
}
} }
/// <summary> /// <summary>
@@ -202,9 +361,21 @@ public static class YouTubeFeedManager
/// </summary> /// </summary>
private static SyndicationItem CreateSyndicationItem(YouTubeVideoItem video) private static SyndicationItem CreateSyndicationItem(YouTubeVideoItem video)
{ {
// フィードタイトルの先頭にチャンネル・ユーザー名を付与(例: 【白上フブキ】 動画タイトル)
string channelName = !string.IsNullOrWhiteSpace(video.ChannelTitle) ? video.ChannelTitle.Trim() : "";
string displayTitle = video.Title;
if (!string.IsNullOrWhiteSpace(channelName))
{
string prefix = $"【{channelName}】";
if (!displayTitle.StartsWith(prefix))
{
displayTitle = $"{prefix} {displayTitle}";
}
}
var item = new SyndicationItem var item = new SyndicationItem
{ {
Title = new TextSyndicationContent(video.Title), Title = new TextSyndicationContent(displayTitle),
Id = CmnUtil.CreateGuid(video.Url), Id = CmnUtil.CreateGuid(video.Url),
PublishDate = video.PublishedDate, PublishDate = video.PublishedDate,
LastUpdatedTime = video.PublishedDate LastUpdatedTime = video.PublishedDate
@@ -244,4 +415,56 @@ public static class YouTubeFeedManager
return item; return item;
} }
/// <summary>
/// カテゴリ名からファイル名用の英数字スラッグを取得します。
/// (未登録のカスタムカテゴリはURLセーフな文字列としてサニタイズされます)
/// </summary>
public static string GetCategoryFileSlug(string category)
{
string norm = (category ?? "").Trim();
if (string.IsNullOrWhiteSpace(norm) || norm == "その他" || norm.Equals("default", StringComparison.OrdinalIgnoreCase) || norm.Equals("other", StringComparison.OrdinalIgnoreCase))
{
return "other"; // その他用のフィード(other_live.xml, other_video.xml, other_shorts.xml)
}
// 一般的な日本語カテゴリ名の英字マッピング
var map = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
{ "野球", "baseball" },
{ "baseball", "baseball" },
{ "ゲーム", "game" },
{ "game", "game" },
{ "音楽", "music" },
{ "music", "music" },
{ "ニュース", "news" },
{ "news", "news" },
{ "アニメ", "anime" },
{ "anime", "anime" },
{ "vtuber", "vtuber" },
{ "料理", "cooking" },
{ "cooking", "cooking" },
{ "スポーツ", "sports" },
{ "sports", "sports" },
{ "apex", "apex" },
{ "公式", "official" },
{ "公式チャンネル", "official" },
{ "official", "official" },
{ "その他", "other" },
{ "other", "other" }
};
if (map.TryGetValue(norm, out var slug))
{
return slug;
}
// 未定義のカテゴリはサニタイズして小文字で使用
string safe = norm;
foreach (char c in System.IO.Path.GetInvalidFileNameChars())
{
safe = safe.Replace(c, '_');
}
return safe.ToLowerInvariant();
}
} }
@@ -31,10 +31,10 @@ public class YouTubeChannelTarget
public string? Name { get; set; } public string? Name { get; set; }
/// <summary> /// <summary>
/// 出力ファイル名のプレフィックス(例: "fubuki" とすると "fubuki_live.xml" などが出力されます) /// 出力カテゴリ名(例: "その他", "野球", "ゲーム", "音楽", "ニュース" 等)
/// 未指定の場合はIdOrHandleから安全な文字列を生成します。 /// カテゴリごとに独立したRSSフィード(XML)が出力されます。
/// </summary> /// </summary>
public string? FilePrefix { get; set; } public string Category { get; set; } = "その他";
/// <summary> /// <summary>
/// 指定したタブ種別に応じたURLを取得します。 /// 指定したタブ種別に応じたURLを取得します。
@@ -71,24 +71,6 @@ public class YouTubeChannelTarget
_ => baseUrl _ => baseUrl
}; };
} }
/// <summary>
/// ファイル名用の安全なプレフィックスを取得します。
/// </summary>
public string GetSafeFilePrefix()
{
if (!string.IsNullOrWhiteSpace(FilePrefix))
{
return FilePrefix.Trim();
}
var prefix = IdOrHandle.Trim().TrimStart('@');
foreach (char c in System.IO.Path.GetInvalidFileNameChars())
{
prefix = prefix.Replace(c, '_');
}
return prefix;
}
} }
/// <summary> /// <summary>
@@ -123,6 +105,9 @@ public class YouTubeVideoItem
/// <summary>フィード種別</summary> /// <summary>フィード種別</summary>
public YouTubeFeedType FeedType { get; set; } public YouTubeFeedType FeedType { get; set; }
/// <summary>所属カテゴリ</summary>
public string Category { get; set; } = "その他";
/// <summary>現在ライブ配信中かどうか</summary> /// <summary>現在ライブ配信中かどうか</summary>
public bool IsLiveNow { get; set; } public bool IsLiveNow { get; set; }
@@ -38,8 +38,8 @@ public static class YouTubeParser
using var doc = JsonDocument.Parse(jsonText); using var doc = JsonDocument.Parse(jsonText);
var root = doc.RootElement; var root = doc.RootElement;
// チャンネル名の抽出(取得できれば設定モデルに反映) // チャンネル名の決定(設定クラスのNameがあれば優先、なければHTMLから自動取得)
string channelTitle = ExtractChannelTitle(root) ?? channel.Name ?? channel.IdOrHandle; string channelTitle = (!string.IsNullOrWhiteSpace(channel.Name) ? channel.Name : ExtractChannelTitle(root)) ?? channel.IdOrHandle;
string channelUrl = channel.GetTabUrl(feedType); string channelUrl = channel.GetTabUrl(feedType);
// tabs から選択中のタブ(または全タブからrichGridRenderer)を走査 // tabs から選択中のタブ(または全タブからrichGridRenderer)を走査
@@ -86,6 +86,7 @@ public static class YouTubeParser
continue; continue;
} }
videoItem.Category = string.IsNullOrWhiteSpace(channel.Category) ? "その他" : channel.Category.Trim();
items.Add(videoItem); items.Add(videoItem);
} }
} }
@@ -175,7 +176,8 @@ public static class YouTubeParser
isUpcoming = true; isUpcoming = true;
publishedText = text; publishedText = text;
} }
else if (text.Contains("前 に配信済み") || text.Contains("配信済み") || text.Contains("前")) else if (text.Contains("前 に配信済み") || text.Contains("配信済み") || text.Contains("前") ||
text.Contains("公開") || Regex.IsMatch(text, @"\d{4}[年/-]\d{1,2}[月/-]\d{1,2}"))
{ {
publishedText = text; publishedText = text;
} }
@@ -236,7 +238,7 @@ public static class YouTubeParser
ChannelTitle = channelTitle, ChannelTitle = channelTitle,
ChannelUrl = channelUrl, ChannelUrl = channelUrl,
PublishedText = publishedText, PublishedText = publishedText,
PublishedDate = ParseRelativeDate(publishedText), PublishedDate = ParsePublishedDate(publishedText),
FeedType = feedType, FeedType = feedType,
IsLiveNow = isLiveNow, IsLiveNow = isLiveNow,
IsUpcoming = isUpcoming, IsUpcoming = isUpcoming,
@@ -364,7 +366,7 @@ public static class YouTubeParser
ChannelTitle = channelTitle, ChannelTitle = channelTitle,
ChannelUrl = channelUrl, ChannelUrl = channelUrl,
PublishedText = publishedText, PublishedText = publishedText,
PublishedDate = ParseRelativeDate(publishedText), PublishedDate = ParsePublishedDate(publishedText),
FeedType = feedType, FeedType = feedType,
IsLiveNow = false, IsLiveNow = false,
IsUpcoming = isUpcoming, IsUpcoming = isUpcoming,
@@ -402,25 +404,54 @@ public static class YouTubeParser
} }
/// <summary> /// <summary>
/// 「2 日前 に配信済み」「3 時間前」などの日本語相対文字列から DateTimeOffset を推定算出します。 /// 「2026/09/02 4:00にプレミア公開」「2 日前 に配信済み」「3 時間前」など
/// 日本語の日時・相対文字列またはISO形式から DateTimeOffset を算出します。
/// </summary> /// </summary>
public static DateTimeOffset ParseRelativeDate(string text) public static DateTimeOffset ParsePublishedDate(string text)
{ {
var now = DateTimeOffset.Now; var now = DateTimeOffset.Now;
if (string.IsNullOrWhiteSpace(text)) return now; if (string.IsNullOrWhiteSpace(text)) return now;
var match = Regex.Match(text, @"(\d+)\s*(秒|分|時間|日|週間|か月|年)前"); // 1. ISO 8601 / RFC 3339 形式の判定
if (match.Success && int.TryParse(match.Groups[1].Value, out int value)) if (DateTimeOffset.TryParse(text, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out var dto))
{ {
string unit = match.Groups[2].Value; return dto;
}
// 2. 日本語絶対日時形式(例: "2026/09/02 4:00にプレミア公開", "2026/08/30 に公開", "2026年9月2日")
var absMatch = Regex.Match(text, @"(?<year>\d{4})[年/-](?<month>\d{1,2})[月/-](?<day>\d{1,2})日?(?:\s+(?<hour>\d{1,2}):(?<minute>\d{2}))?");
if (absMatch.Success)
{
if (int.TryParse(absMatch.Groups["year"].Value, out int y) &&
int.TryParse(absMatch.Groups["month"].Value, out int m) &&
int.TryParse(absMatch.Groups["day"].Value, out int d))
{
int h = absMatch.Groups["hour"].Success && int.TryParse(absMatch.Groups["hour"].Value, out int parsedH) ? parsedH : 0;
int min = absMatch.Groups["minute"].Success && int.TryParse(absMatch.Groups["minute"].Value, out int parsedMin) ? parsedMin : 0;
try
{
return new DateTimeOffset(y, m, d, h, min, 0, TimeSpan.FromHours(9));
}
catch
{
// 万一無効な日付の場合は相対パースへフォールバック
}
}
}
// 3. 相対日時形式(例: "2 日前 に配信済み", "3 時間前", "2 週間前", "1 か月前")
var relMatch = Regex.Match(text, @"(\d+)\s*(秒|分|時間|日|週間|週|か月|ヶ月|月|年)前");
if (relMatch.Success && int.TryParse(relMatch.Groups[1].Value, out int value))
{
string unit = relMatch.Groups[2].Value;
return unit switch return unit switch
{ {
"秒" => now.AddSeconds(-value), "秒" => now.AddSeconds(-value),
"分" => now.AddMinutes(-value), "分" => now.AddMinutes(-value),
"時間" => now.AddHours(-value), "時間" => now.AddHours(-value),
"日" => now.AddDays(-value), "日" => now.AddDays(-value),
"週間" => now.AddDays(-value * 7), "週間" or "週" => now.AddDays(-value * 7),
"か月" => now.AddMonths(-value), "か月" or "ヶ月" or "月" => now.AddMonths(-value),
"年" => now.AddYears(-value), "年" => now.AddYears(-value),
_ => now _ => now
}; };
@@ -428,4 +459,9 @@ public static class YouTubeParser
return now; return now;
} }
/// <summary>
/// 互換用メソッド
/// </summary>
public static DateTimeOffset ParseRelativeDate(string text) => ParsePublishedDate(text);
} }
+1 -1
View File
@@ -83,8 +83,8 @@ while (true)
//tasks.Add(momonga_fanzine.CreateRSSAsync(client)); //tasks.Add(momonga_fanzine.CreateRSSAsync(client));
//tasks.Add(momonga_magazine.CreateRSSAsync(client)); //tasks.Add(momonga_magazine.CreateRSSAsync(client));
//tasks.Add(e_hentai_non_ai.CreateRSSAsync(client)); //tasks.Add(e_hentai_non_ai.CreateRSSAsync(client));
//tasks.Add(Youtube.CreateRSSAsync(client));
#else #else
tasks.Add(Youtube.CreateRSSAsync(client));
tasks.Add(YouTubeFeedManager.CreateRSSAsync(client)); tasks.Add(YouTubeFeedManager.CreateRSSAsync(client));
tasks.Add(rss_generator.Class.RSS.X.x_list.CreateRSSAsync(client)); tasks.Add(rss_generator.Class.RSS.X.x_list.CreateRSSAsync(client));