跳至內容
信仰百科
使用者工具
註冊
登入
網站工具
搜尋
工具
顯示頁面
舊版
反向連結
最近更新
多媒體管理器
網站地圖
註冊
登入
>
最近更新
多媒體管理器
網站地圖
足跡:
工具:youtuberss
本頁是唯讀的,您可以看到原始碼,但不能更動它。您如果覺得它不應被鎖上,請詢問管理員。
===== 任何 YouTube 頻道變成 RSS 的規則範例 ===== ==== 例如 ==== * https://www.youtube.com/channel/UCXXHhxHgPj_QXAqLxrepC4g ==== 可以得到 ==== * 整個頻道 RSS = \\ https://www.youtube.com/feeds/videos.xml?channel_id=UCXXHhxHgPj_QXAqLxrepC4g * 整個頻道視為一個播放清單的 RSS = \\ https://www.youtube.com/feeds/videos.xml?playlist_id=UUXXHhxHgPj_QXAqLxrepC4g * 輪播的 embed target url = \\ https://www.youtube.com/embed/videoseries?list=UUXXHhxHgPj_QXAqLxrepC4g&index=0&loop=1&autoplay=1 * 輪播 embed url 等同於 \\ https://www.youtube.com/embed/?listType=playlist&list=UUXXHhxHgPj_QXAqLxrepC4g&index=0&loop=1&autoplay=1 * 這四種方式,上面兩個有同樣效果,下面兩個也有同樣效果。 ---- === JavaScript Code === * 於 https://www.youtube.com/channel/xxxx 畫面下,使用:\\ <code> javascript:function copy(s) { var clip_area = document.createElement('textarea'); clip_area.textContent = s; document.body.appendChild(clip_area); clip_area.select(); document.execCommand('copy'); clip_area.remove(); } var regex_playlist = /https?:\/\/www.youtube.com\/([^\/\&]{1,})(&|\?)(p|list|playlist_id)=([^\/&]{1,})(.*)/gi; if(regex_playlist.test(document.location.href)){ var playlist_id = document.location.href.replace(regex_playlist,'$4'); copy('https://www.youtube.com/feeds/videos.xml?playlist_id=' + playlist_id); console.log('播放清單 RSS https://www.youtube.com/feeds/videos.xml?playlist_id=' + playlist_id); console.log('輪播的 embed target url = ' + 'https://www.youtube.com/embed/videoseries?list=' + playlist_id + '&index=0&loop=1&autoplay=1'); console.log('輪播 embed url 等同於 ' + 'https://www.youtube.com/embed/?listType=playlist&list=' + playlist_id + '&index=0&loop=1&autoplay=1'); }else{ var channel_id = ''; if(window["ytInitialData"].metadata!==undefined){ var channel_id = window["ytInitialData"].metadata.channelMetadataRenderer.externalId; document.location.href.replace(regex,'$1'); }else{ var regex = /https?:\/\/www.youtube.com\/channel\/([^\/]{1,})(\/.*|.*$)/gi; if(regex.test(document.location.href)){ channel_id = document.location.href.replace(regex,'$1'); } } if(channel_id!=''){ copy('https://www.youtube.com/feeds/videos.xml?channel_id=' + channel_id); console.log('頻道 RSS = https://www.youtube.com/feeds/videos.xml?channel_id=' + channel_id); console.log('整個頻道視為一個播放清單的 RSS https://www.youtube.com/feeds/videos.xml?playlist_id=' + channel_id.replace('UC','UU')); console.log('輪播的 embed target url = ' + 'https://www.youtube.com/embed/videoseries?list=' + channel_id.replace('UC','UU') + '&index=0&loop=1&autoplay=1'); console.log('輪播 embed url 等同於 ' + 'https://www.youtube.com/embed/?listType=playlist&list=' + channel_id.replace('UC','UU') + '&index=0&loop=1&autoplay=1'); }else{ if(/^https?:\/\/(.*\.youtube\.com\/watch\?v\=|youtu\.be\/)([^&|^?]*)($|\&.*$|\?.*$)/gi.test(document.location.href)){/*window.prompt('',*/copy(`<iframe width="560" height="315" src="` + document.location.href.replace(/^https?:\/\/(.*\.youtube\.com\/watch\?v\=|youtu\.be\/)([^&|^?]*)($|\&.*$|\?.*$)/gi,'https://www.youtube.com/embed/$2') + `" frameborder="0" allowfullscreen></iframe>`);} } }</code> * 效果:\\ 直接自動複製 https://www.youtube.com/feeds/videos.xml?channel_id=UCXXXXXXXXX \\ 並在 console.log((Chrome + F12 並選擇「console」就可以看 console.log)) 留下其他的 RSS 網址。 ---- ===== 技巧 ===== * 每個 YouTube 裡面的原始碼都會有一段 <code><link rel="canonical" href="https://www.youtube.com/channel/UC開頭的"></code> * 直接搜尋 <code>canonical" href="https</code>可以快速找到 UC 開頭的 YouTube 頻道 ID * 以此範例來說,<code>UCXXHhxHgPj_QXAqLxrepC4g</code> 寫成播放清單的時候會變成 playlist_id=UUXXHhxHgPj_QXAqLxrepC4g,\\ 實際上就是把 UC 開頭取代成UU 開頭。 ==== 這個技巧的使用時機 ==== * 基本上 YouTube 大致上有兩種 * 一種是網址列上面有 user,尚未變成 [[https://support.google.com/youtube/answer/3056283?hl=zh-Hant|Google 品牌帳號]] 來管理的個人頻道。 * 嚴格來說推薦全都弄成品牌帳號,多人共管共編、權責分明。 * 另一種網址列本身已帶有 channel * 而我們發現的 RSS 相關規則都針對 channel 之下,UC 開頭的那串 ID 來組合使用。\\ 所以需要這個技巧,把 user 網址裡面實際的頻道 ID 找出來。 * 當然這是手動的方式,也可能有其他自動化的方式((YouTube API?))可以達成一樣查詢頻道 ID 的目的。 ---- ===== 其他 ===== * 在更早之前,每個 YouTube 頁面的原始碼都可以觀察到,都有設定標準的 RSS 寫法。\\ 但最近陸續一些頁面已經沒有這個部分。\\ 所以相關當時觀察下來的使用規則,特別在這裡做記錄與說明。 * 當然這種方式的 RSS 組合寫法,不確定可以用到什麼時候。 * 但至少這兩年觀察下來是都沒有任何要收掉的變化或預兆。\\ 基本上如有 RSS YouTube 需求,還是推薦使用。 * 最確認存活可用時間點為 2019/07/22 18:44([[https://pansci.asia/archives/84978|GMT+8]])
工具/youtuberss.txt
· 上一次變更: 2024/09/03 17:44 由
127.0.0.1
頁面工具
顯示頁面
舊版
反向連結
回到頁頂