Use 1 day ranking for trending videos

This commit is contained in:
the1812 2019-10-27 18:20:38 +08:00
parent cd2502515b
commit 842b61942d
10 changed files with 24 additions and 24 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -52,7 +52,7 @@
"expand-description.min.css": "58C7710A50521B80F7D872BDC4C652610D84C4FABC6874BA66DA37B4F8759224", "expand-description.min.css": "58C7710A50521B80F7D872BDC4C652610D84C4FABC6874BA66DA37B4F8759224",
"expand-description.min.js": "A56857AD6B1C9F431B233D188E857D30DD5A2EB644986DE32A21280B1B7BC7A7", "expand-description.min.js": "A56857AD6B1C9F431B233D188E857D30DD5A2EB644986DE32A21280B1B7BC7A7",
"favorites-redirect.min.js": "70D6ECCE0402AA76387D2A3288C1148C60CC88D5378B7A2BDC813F3F78E4EE84", "favorites-redirect.min.js": "70D6ECCE0402AA76387D2A3288C1148C60CC88D5378B7A2BDC813F3F78E4EE84",
"feeds-apis.min.js": "8859B24FA8724340FC90B9BF89D5DBF3C55C24B418DDF29BBF832EF6EFA61251", "feeds-apis.min.js": "535CB108EAA52E2918D8E75EAA4BB2D6F59D27AB775A99C0D22B25A8CABA4E93",
"feeds-filter-card.vue.min.js": "5922DD76080D5DD57C860018749BD3D82530DDBD537DBFB5D540D10C03645775", "feeds-filter-card.vue.min.js": "5922DD76080D5DD57C860018749BD3D82530DDBD537DBFB5D540D10C03645775",
"feeds-filter.min.js": "10557E498B8BADA3C1C03E8C1DCD6FB24DBA2DA27A5A03BD861054F7E2989D46", "feeds-filter.min.js": "10557E498B8BADA3C1C03E8C1DCD6FB24DBA2DA27A5A03BD861054F7E2989D46",
"filter-type-switch.vue.min.js": "86F40D40C2464A56A2A0D32A0B94860DD376D1FE7850836B4CE37B767312BBE7", "filter-type-switch.vue.min.js": "86F40D40C2464A56A2A0D32A0B94860DD376D1FE7850836B4CE37B767312BBE7",
@ -160,7 +160,7 @@
"touch-player.min.css": "C1988B4756185611653E666C0C9E825C9B6AA36FA47D362CC2CD9390DC1E2281", "touch-player.min.css": "C1988B4756185611653E666C0C9E825C9B6AA36FA47D362CC2CD9390DC1E2281",
"touch-player.min.js": "5CA0C5A0621330ABBD62B31042ADDF9019D27DEA7D58B69CB959C90B25D8C8F5", "touch-player.min.js": "5CA0C5A0621330ABBD62B31042ADDF9019D27DEA7D58B69CB959C90B25D8C8F5",
"trending-videos.min.js": "FB1507281A70FADBFC51B2BD5A94F765868F380673B5A1ECE19E4E333A383625", "trending-videos.min.js": "FB1507281A70FADBFC51B2BD5A94F765868F380673B5A1ECE19E4E333A383625",
"trending-videos.vue.min.js": "AB940B24961870F52DEC3142D04E506828A1D4CF427F0A6F8E998BBFBF5BB2D0", "trending-videos.vue.min.js": "AB6BE146C6428791BCC8C3E16F73CCD1661449F0375FE24785AD84DD7D14A76A",
"tweets.min.css": "9015C1F165C91B9205ABBE4E8A3B5FA83DB1EB4B5CF2442846AF61E44FF178A8", "tweets.min.css": "9015C1F165C91B9205ABBE4E8A3B5FA83DB1EB4B5CF2442846AF61E44FF178A8",
"v-checkbox.vue.min.js": "A23C35D5627009A29FD396A024442A19E37DEE70674BF3CE0FA377D781ED2231", "v-checkbox.vue.min.js": "A23C35D5627009A29FD396A024442A19E37DEE70674BF3CE0FA377D781ED2231",
"v-dropdown.vue.min.js": "66C883695F6653412980050A23F7581557407A2859214BF0CAAEC7001D0B5DDB", "v-dropdown.vue.min.js": "66C883695F6653412980050A23F7581557407A2859214BF0CAAEC7001D0B5DDB",

Binary file not shown.

View File

@ -1 +1 @@
(()=>{return(e,t)=>{const a={repost:{id:1,name:"转发"},textWithImages:{id:2,name:"图文"},text:{id:4,name:"文字"},video:{id:8,name:"视频"},miniVideo:{id:16,name:"小视频"},column:{id:64,name:"专栏"},audio:{id:256,name:"音频"},bangumi:{id:512,name:"番剧"},share:{id:2048,name:"分享"}};class n extends EventTarget{constructor(){super(...arguments);this.cards=[]}addEventListener(e,t,a){super.addEventListener(e,t,a)}removeEventListener(e,t,a){super.removeEventListener(e,t,a)}async addCard(e){if(e instanceof HTMLElement&&e.classList.contains("card")){if(e.querySelector(".skeleton")!==null){const t=Observer.childList(e,()=>{if(e.querySelector(".skeleton")===null){t.forEach(e=>e.stop());this.addCard(e)}})}else{const t=await this.parseCard(e);this.cards.push(t);const a=new CustomEvent("addCard",{detail:t});this.dispatchEvent(a)}}}async removeCard(e){if(e instanceof HTMLElement&&e.classList.contains("card")){const t=(await this.parseCard(e)).id;const a=this.cards.findIndex(e=>e.id===t);const n=this.cards[a];this.cards.splice(a,1);const i=new CustomEvent("removeCard",{detail:n});this.dispatchEvent(i)}}async parseCard(e){const t=async t=>{const a=await SpinQuery.condition(()=>e.querySelector(t),e=>e!==null);if(a===null){console.warn(e,t);return""}return a.innerText};const n=async e=>{const a=parseInt(await t(e));if(isNaN(a)){return 0}return a};const i=(()=>{if(e.querySelector(".repost")){return a.repost}if(e.querySelector(".imagesbox")){return a.textWithImages}if(e.querySelector(".video-container")){return a.video}if(e.querySelector(".bangumi-container")){return a.bangumi}if(e.querySelector(".article-container")){return a.column}if(e.querySelector(".music-container")){return a.audio}if(e.querySelector(".h5share-container")){return a.share}if(e.querySelector(".vc-ctnr")){return a.miniVideo}return a.text})();const r={id:e.getAttribute("data-did"),username:await t(".main-content .user-name"),text:await t(".card-content .text.description"),reposts:await n(".button-bar .single-button:nth-child(1) .text-offset"),comments:await n(".button-bar .single-button:nth-child(2) .text-offset"),likes:await n(".button-bar .single-button:nth-child(3) .text-offset"),element:e,type:i};e.setAttribute("data-type",i.id.toString());return r}async startWatching(){const e=await SpinQuery.select(".card-list .content");if(!e){return false}const t=[...e.querySelectorAll(".content>.card")];t.forEach(e=>this.addCard(e));Observer.childList(e,e=>{e.forEach(e=>{e.addedNodes.forEach(e=>this.addCard(e));e.removedNodes.forEach(e=>this.removeCard(e))})});return true}}const i=new n;const r=async(e="video")=>{const a=await Ajax.getJsonWithCredentials(`https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=${getUID()}&type_list=${e==="video"?8:512}`);if(a.code!==0){throw new Error(a.message)}if(e==="video"){const{getWatchlaterList:e}=await t.importAsync("watchlater-api");const n=await e();return a.data.cards.map(e=>{const t=JSON.parse(e.card);const a=_.get(e,"display.topic_info.topic_details",[]).map(e=>{return{id:e.topic_id,name:e.topic_name}});return{id:e.desc.dynamic_id_str,aid:t.aid,title:t.title,upID:e.desc.user_profile.info.uid,upName:e.desc.user_profile.info.uname,upFaceUrl:e.desc.user_profile.info.face,coverUrl:t.pic,description:t.desc,timestamp:e.timestamp,time:new Date(e.timestamp*1e3),topics:a,dynamic:t.dynamic,like:formatCount(e.desc.like),duration:t.duration,durationText:formatDuration(t.duration,0),playCount:formatCount(t.stat.view),danmakuCount:formatCount(t.stat.danmaku),watchlater:n.includes(t.aid)}})}else if(e==="bangumi"){return a.data.cards.map(e=>{const t=JSON.parse(e.card);return{id:e.desc.dynamic_id_str,aid:t.aid,epID:t.episode_id,title:t.new_desc,upName:t.apiSeasonInfo.title,upFaceUrl:t.apiSeasonInfo.cover,coverUrl:t.cover,description:"",timestamp:e.timestamp,time:new Date(e.timestamp*1e3),like:formatCount(e.desc.like),durationText:"",playCount:formatCount(t.play_count),danmakuCount:formatCount(t.bullet_count),watchlater:false}})}else{return[]}};return{export:{feedsCardsManager:i,feedsCardTypes:a,getVideoFeeds:r}}}})(); (()=>{return(e,t)=>{const a={repost:{id:1,name:"转发"},textWithImages:{id:2,name:"图文"},text:{id:4,name:"文字"},video:{id:8,name:"视频"},miniVideo:{id:16,name:"小视频"},column:{id:64,name:"专栏"},audio:{id:256,name:"音频"},bangumi:{id:512,name:"番剧"},share:{id:2048,name:"分享"}};class i extends EventTarget{constructor(){super(...arguments);this.cards=[]}addEventListener(e,t,a){super.addEventListener(e,t,a)}removeEventListener(e,t,a){super.removeEventListener(e,t,a)}async addCard(e){if(e instanceof HTMLElement&&e.classList.contains("card")){if(e.querySelector(".skeleton")!==null){const t=Observer.childList(e,()=>{if(e.querySelector(".skeleton")===null){t.stop();this.addCard(e)}})}else{const t=await this.parseCard(e);this.cards.push(t);const a=new CustomEvent("addCard",{detail:t});this.dispatchEvent(a)}}}async removeCard(e){if(e instanceof HTMLElement&&e.classList.contains("card")){const t=(await this.parseCard(e)).id;const a=this.cards.findIndex(e=>e.id===t);const i=this.cards[a];this.cards.splice(a,1);const n=new CustomEvent("removeCard",{detail:i});this.dispatchEvent(n)}}async parseCard(e){const t=async t=>{const a=await SpinQuery.condition(()=>e.querySelector(t),e=>e!==null);if(a===null){return""}return a.innerText};const i=async e=>{const a=parseInt(await t(e));if(isNaN(a)){return 0}return a};const n=(()=>{if(e.querySelector(".repost")){return a.repost}if(e.querySelector(".imagesbox")){return a.textWithImages}if(e.querySelector(".video-container")){return a.video}if(e.querySelector(".bangumi-container")){return a.bangumi}if(e.querySelector(".article-container")){return a.column}if(e.querySelector(".music-container")){return a.audio}if(e.querySelector(".h5share-container")){return a.share}if(e.querySelector(".vc-ctnr")){return a.miniVideo}return a.text})();const r={id:e.getAttribute("data-did"),username:await t(".main-content .user-name"),text:await t(".card-content .text.description"),reposts:await i(".button-bar .single-button:nth-child(1) .text-offset"),comments:await i(".button-bar .single-button:nth-child(2) .text-offset"),likes:await i(".button-bar .single-button:nth-child(3) .text-offset"),element:e,type:n};e.setAttribute("data-type",n.id.toString());return r}async startWatching(){const e=await SpinQuery.select(".card-list .content");if(!e){return false}const t=[...e.querySelectorAll(".content>.card")];t.forEach(e=>this.addCard(e));Observer.childList(e,e=>{e.forEach(e=>{e.addedNodes.forEach(e=>this.addCard(e));e.removedNodes.forEach(e=>this.removeCard(e))})});return true}}const n=new i;const r=async(e="video")=>{const a=await Ajax.getJsonWithCredentials(`https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=${getUID()}&type_list=${e==="video"?8:512}`);if(a.code!==0){throw new Error(a.message)}if(e==="video"){const{getWatchlaterList:e}=await t.importAsync("watchlater-api");const i=await e();return a.data.cards.map(e=>{const t=JSON.parse(e.card);const a=_.get(e,"display.topic_info.topic_details",[]).map(e=>{return{id:e.topic_id,name:e.topic_name}});return{id:e.desc.dynamic_id_str,aid:t.aid,title:t.title,upID:e.desc.user_profile.info.uid,upName:e.desc.user_profile.info.uname,upFaceUrl:e.desc.user_profile.info.face,coverUrl:t.pic,description:t.desc,timestamp:e.timestamp,time:new Date(e.timestamp*1e3),topics:a,dynamic:t.dynamic,like:formatCount(e.desc.like),duration:t.duration,durationText:formatDuration(t.duration,0),playCount:formatCount(t.stat.view),danmakuCount:formatCount(t.stat.danmaku),watchlater:i.includes(t.aid)}})}else if(e==="bangumi"){return a.data.cards.map(e=>{const t=JSON.parse(e.card);return{id:e.desc.dynamic_id_str,aid:t.aid,epID:t.episode_id,title:t.new_desc,upName:t.apiSeasonInfo.title,upFaceUrl:t.apiSeasonInfo.cover,coverUrl:t.cover,description:"",timestamp:e.timestamp,time:new Date(e.timestamp*1e3),like:formatCount(e.desc.like),durationText:"",playCount:formatCount(t.play_count),danmakuCount:formatCount(t.bullet_count),watchlater:false}})}else{return[]}};return{export:{feedsCardsManager:n,feedsCardTypes:a,getVideoFeeds:r}}}})();

View File

@ -1 +1 @@
(()=>{return(a,n)=>{const t=`<div class=trendings><div class=header><div class=title>热门</div><div class=tabs><div class=tab v-for="tab in tabs":key=tab.day @click=changeTab(tab) :class="{active: currentTab === tab}"><div class=tab-name>{{tab.name}}</div></div></div></div><div class=contents><div class=card-wrapper v-for="card in trendingCards":key=card.id><video-card :data=card orientation=vertical></video-card></div></div></div>`;n.applyStyleFromText(`.simple-home .trendings{display:flex;flex-direction:column}.simple-home .trendings .header{padding:0 8px}.simple-home .trendings .contents{--card-width:200px;--card-height:250px;--card-count:3;margin-top:16px;display:flex;overflow:auto;height:calc(var(--card-height) + 16px);width:calc((var(--card-width) + 16px) * var(--card-count));scroll-snap-type:x mandatory;scrollbar-width:none!important}@media screen and (max-width:1250px) and (min-width:900px){.simple-home .trendings .contents{--card-count:2}}@media screen and (max-width:1050px) and (min-width:900px){.simple-home .trendings .contents{--card-count:1}}@media screen and (min-width:1600px){.simple-home .trendings .contents{--card-count:4}}@media screen and (min-width:1900px){.simple-home .trendings .contents{--card-count:5}}.simple-home .trendings .contents::-webkit-scrollbar{width:0!important;height:0!important}.simple-home .trendings .contents .card-wrapper{padding:0 8px;scroll-snap-align:start;flex-shrink:0}`,"trending-videos-style");const e=[{name:"一周",day:7,url:"https://www.bilibili.com/ranking/all/0/0/7"},{name:"三日",day:3,url:"https://www.bilibili.com/ranking"},{name:"昨日",day:1,url:"https://www.bilibili.com/ranking/all/0/0/1"}];return{export:Object.assign({template:t},{components:{VideoCard:()=>n.importAsync("video-card.vue")},data(){return{tabs:e,currentTab:e[0],trendingCards:[]}},watch:{currentTab(a){this.updateTrendingTab(a)}},methods:{async updateTrendingTab(a){const{getTrendingVideos:t}=await n.importAsync("trending-videos");this.trendingCards=await t(a.day)},changeTab(a){if(this.currentTab===a){open(a.url,"_blank")}else{this.currentTab=a}}},mounted(){this.updateTrendingTab(this.currentTab)}})}}})(); (()=>{return(a,n)=>{const t=`<div class=trendings><div class=header><div class=title>热门</div><div class=tabs><div class=tab v-for="tab in tabs":key=tab.day @click=changeTab(tab) :class="{active: currentTab === tab}"><div class=tab-name>{{tab.name}}</div></div></div></div><div class=contents><div class=card-wrapper v-for="card in trendingCards":key=card.id><video-card :data=card orientation=vertical></video-card></div></div></div>`;n.applyStyleFromText(`.simple-home .trendings{display:flex;flex-direction:column}.simple-home .trendings .header{padding:0 8px}.simple-home .trendings .contents{--card-width:200px;--card-height:250px;--card-count:3;margin-top:16px;display:flex;overflow:auto;height:calc(var(--card-height) + 16px);width:calc((var(--card-width) + 16px) * var(--card-count));scroll-snap-type:x mandatory;scrollbar-width:none!important}@media screen and (max-width:1250px) and (min-width:900px){.simple-home .trendings .contents{--card-count:2}}@media screen and (max-width:1050px) and (min-width:900px){.simple-home .trendings .contents{--card-count:1}}@media screen and (min-width:1600px){.simple-home .trendings .contents{--card-count:4}}@media screen and (min-width:1900px){.simple-home .trendings .contents{--card-count:5}}.simple-home .trendings .contents::-webkit-scrollbar{width:0!important;height:0!important}.simple-home .trendings .contents .card-wrapper{padding:0 8px;scroll-snap-align:start;flex-shrink:0}`,"trending-videos-style");const e=[{name:"昨日",day:1,url:"https://www.bilibili.com/ranking/all/0/0/1"},{name:"三日",day:3,url:"https://www.bilibili.com/ranking"},{name:"一周",day:7,url:"https://www.bilibili.com/ranking/all/0/0/7"}];return{export:Object.assign({template:t},{components:{VideoCard:()=>n.importAsync("video-card.vue")},data(){return{tabs:e,currentTab:e[0],trendingCards:[]}},watch:{currentTab(a){this.updateTrendingTab(a)}},methods:{async updateTrendingTab(a){const{getTrendingVideos:t}=await n.importAsync("trending-videos");this.trendingCards=await t(a.day)},changeTab(a){if(this.currentTab===a){open(a.url,"_blank")}else{this.currentTab=a}}},mounted(){this.updateTrendingTab(this.currentTab)}})}}})();

View File

@ -102,7 +102,7 @@ class FeedsCardsManager extends EventTarget {
it => it !== null it => it !== null
) as HTMLElement ) as HTMLElement
if (subElement === null) { if (subElement === null) {
console.warn(element, selector) // console.warn(element, selector)
return '' return ''
} }
return subElement.innerText return subElement.innerText

View File

@ -30,24 +30,24 @@ interface Tab {
} }
const tabs: Tab[] = [ const tabs: Tab[] = [
{ {
name: '一周', name: '昨日',
day: 7, day: 1,
url: 'https://www.bilibili.com/ranking/all/0/0/7', url: 'https://www.bilibili.com/ranking/all/0/0/1'
}, },
{ {
name: '三日', name: '三日',
day: 3, day: 3,
url: 'https://www.bilibili.com/ranking', url: 'https://www.bilibili.com/ranking'
}, },
{ {
name: '昨日', name: '一周',
day: 1, day: 7,
url: 'https://www.bilibili.com/ranking/all/0/0/1', url: 'https://www.bilibili.com/ranking/all/0/0/7'
} }
] ]
export default { export default {
components: { components: {
VideoCard: () => import('../video-card.vue'), VideoCard: () => import('../video-card.vue')
}, },
data() { data() {
return { return {
@ -76,7 +76,7 @@ export default {
}, },
mounted() { mounted() {
this.updateTrendingTab(this.currentTab) this.updateTrendingTab(this.currentTab)
}, }
} }
</script> </script>