Update feeds apis

This commit is contained in:
the1812 2020-02-28 11:49:38 +08:00
parent 751376d442
commit f379ed7118
11 changed files with 51 additions and 18 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

@ -76,9 +76,9 @@
"expand-description.min.css": "58C7710A50521B80F7D872BDC4C652610D84C4FABC6874BA66DA37B4F8759224",
"expand-description.min.js": "A56857AD6B1C9F431B233D188E857D30DD5A2EB644986DE32A21280B1B7BC7A7",
"favorites-redirect.min.js": "70D6ECCE0402AA76387D2A3288C1148C60CC88D5378B7A2BDC813F3F78E4EE84",
"feeds-apis.min.js": "145BED87E33CFB2E937BD8FC1F460C307C8C09F273FBDBF01D5EA3237BFA8910",
"feeds-apis.min.js": "FB079652CED58A4442B95D407955E9E5207E9434DE2BA0019AD52F9C35B92FBD",
"feeds-filter.min.js": "10557E498B8BADA3C1C03E8C1DCD6FB24DBA2DA27A5A03BD861054F7E2989D46",
"feeds-filter-card.vue.min.js": "282140DDBC3D2C94F821C8F4E0047BC7B3DDFB91837C7896F837353A0AD541F0",
"feeds-filter-card.vue.min.js": "922E7201AD48573E00123C36A61246ECB3F957AC9C97712A7E0CD5B01C2BEBA8",
"feeds-translate.min.css": "D2FDDFD71335889D19F1EADAA07862FF2587AE712D42039A58CF8C7E599A9444",
"feeds-translate.min.js": "6EDDC72E562895EC263D6D1DF8055F99E8C1B1863DB950B23469B3C78F03FD84",
"feeds-translate-providers.min.js": "D938CB5F6437AE4A38C1A9933F530B89168FB4E88DCA2289C46465059CE6473C",

Binary file not shown.

View File

@ -1 +1 @@
(()=>{return(t,e)=>{const r={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:"分享"}};const i=t=>{if(t.querySelector(".repost")){return r.repost}if(t.querySelector(".imagesbox")){return r.textWithImages}if(t.querySelector(".video-container")){return r.video}if(t.querySelector(".bangumi-container")){return r.bangumi}if(t.querySelector(".article-container")){return r.column}if(t.querySelector(".music-container")){return r.audio}if(t.querySelector(".h5share-container")){return r.share}if(t.querySelector(".vc-ctnr")){return r.miniVideo}return r.text};class n extends EventTarget{constructor(){super(...arguments);this.watching=false;this.cards=[]}addEventListener(t,e,r){super.addEventListener(t,e,r)}removeEventListener(t,e,r){super.removeEventListener(t,e,r)}async addCard(t){if(t instanceof HTMLElement&&t.classList.contains("card")){if(t.querySelector(".skeleton")!==null){const e=Observer.childList(t,()=>{if(t.querySelector(".skeleton")===null){e.stop();this.addCard(t)}})}else{const e=await this.parseCard(t);this.cards.push(e);this.cards.sort((t,e)=>{if(t.id===e.id){return 0}return t.id>e.id?-1:1});const r=new CustomEvent("addCard",{detail:e});this.dispatchEvent(r)}}}async removeCard(t){if(t instanceof HTMLElement&&t.classList.contains("card")){const e=(await this.parseCard(t)).id;const r=this.cards.findIndex(t=>t.id===e);const i=this.cards[r];this.cards.splice(r,1);const n=new CustomEvent("removeCard",{detail:i});this.dispatchEvent(n)}}async parseCard(t){const e=async e=>{const r=await SpinQuery.condition(()=>t.querySelector(e),t=>t!==null);if(r===null){console.warn(t,e);return""}const i=r.innerText.trim();return i};const n=async e=>{if(e===r.bangumi){return""}const i=await SpinQuery.condition(()=>t,t=>Boolean(t.__vue__));if(i===null){console.warn(i);return""}if(e===r.repost){const t=i.__vue__.originCardData.pureText;return i.__vue__.card.item.content+"\n"+t||""}return i.__vue__.originCardData.pureText||""};const a=async t=>{const r=parseInt(await e(t));if(isNaN(r)){return 0}return r};const s={id:t.getAttribute("data-did"),username:await e(".main-content .user-name"),text:"",reposts:await a(".button-bar .single-button:nth-child(1) .text-offset"),comments:await a(".button-bar .single-button:nth-child(2) .text-offset"),likes:await a(".button-bar .single-button:nth-child(3) .text-offset"),element:t,type:i(t),async getText(){const t=await n(this.type);this.text=t;return t}};await s.getText();t.setAttribute("data-type",s.type.id.toString());return s}async startWatching(){const t=await SpinQuery.select(".card-list .content");if(!t){return false}if(this.watching){return true}this.watching=true;const e=[...t.querySelectorAll(".content>.card")];e.forEach(t=>this.addCard(t));Observer.childList(t,t=>{t.forEach(t=>{t.addedNodes.forEach(t=>this.addCard(t));t.removedNodes.forEach(t=>this.removeCard(t))})});return true}}const a=new n;const s=async(t="video")=>{if(!getUID()){return[]}const e=await Ajax.getJsonWithCredentials(`https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=${getUID()}&type_list=${t==="video"?8:512}`);if(e.code!==0){throw new Error(e.message)}if(t==="video"){return e.data.cards.filter(t=>{return t.desc.orig_dy_id===0}).map(t=>{const e=JSON.parse(t.card);const r=_.get(t,"display.topic_info.topic_details",[]).map(t=>{return{id:t.topic_id,name:t.topic_name}});return{id:t.desc.dynamic_id_str,aid:e.aid,title:e.title,upID:t.desc.user_profile.info.uid,upName:t.desc.user_profile.info.uname,upFaceUrl:t.desc.user_profile.info.face,coverUrl:e.pic,description:e.desc,timestamp:t.timestamp,time:new Date(t.timestamp*1e3),topics:r,dynamic:e.dynamic,like:formatCount(t.desc.like),duration:e.duration,durationText:formatDuration(e.duration,0),playCount:formatCount(e.stat.view),danmakuCount:formatCount(e.stat.danmaku),watchlater:store.state.watchlaterList.includes(e.aid)}})}else if(t==="bangumi"){return e.data.cards.map(t=>{const e=JSON.parse(t.card);return{id:t.desc.dynamic_id_str,aid:e.aid,epID:e.episode_id,title:e.new_desc,upName:e.apiSeasonInfo.title,upFaceUrl:e.apiSeasonInfo.cover,coverUrl:e.cover,description:"",timestamp:t.timestamp,time:new Date(t.timestamp*1e3),like:formatCount(t.desc.like),durationText:"",playCount:formatCount(e.play_count),danmakuCount:formatCount(e.bullet_count),watchlater:false}})}else{return[]}};return{export:{feedsCardsManager:a,feedsCardTypes:r,getVideoFeeds:s}}}})();
(()=>{return(e,t)=>{const i={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:"分享"},manga:{id:2049,name:"漫画"},film:{id:4098,name:"电影"},tv:{id:4099,name:"TV剧"},chinese:{id:4100,name:"国创"},documentary:{id:4101,name:"纪录片"},mediaList:{id:4300,name:"收藏夹"}};const n=e=>{if(e.querySelector(".repost")){return i.repost}if(e.querySelector(".imagesbox")){return i.textWithImages}if(e.querySelector(".video-container")){return i.video}if(e.querySelector(".bangumi-container")){return i.bangumi}if(e.querySelector(".article-container")){return i.column}if(e.querySelector(".music-container")){return i.audio}if(e.querySelector(".h5share-container")){return i.share}if(e.querySelector(".vc-ctnr")){return i.miniVideo}return i.text};class r extends EventTarget{constructor(){super(...arguments);this.watching=false;this.cards=[]}addEventListener(e,t,i){super.addEventListener(e,t,i)}removeEventListener(e,t,i){super.removeEventListener(e,t,i)}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);this.cards.sort((e,t)=>{if(e.id===t.id){return 0}return e.id>t.id?-1:1});const i=new CustomEvent("addCard",{detail:t});this.dispatchEvent(i)}}}async removeCard(e){if(e instanceof HTMLElement&&e.classList.contains("card")){const t=(await this.parseCard(e)).id;const i=this.cards.findIndex(e=>e.id===t);const n=this.cards[i];this.cards.splice(i,1);const r=new CustomEvent("removeCard",{detail:n});this.dispatchEvent(r)}}async parseCard(e){const t=async t=>{const i=await SpinQuery.condition(()=>e.querySelector(t),e=>e!==null);if(i===null){console.warn(e,t);return""}const n=i.innerText.trim();return n};const r=async t=>{if(t===i.bangumi){return""}const n=await SpinQuery.condition(()=>e,e=>Boolean(e.__vue__));if(n===null){console.warn(n);return""}if(t===i.repost){const e=n.__vue__.originCardData.pureText;return n.__vue__.card.item.content+"\n"+e||""}return n.__vue__.originCardData.pureText||""};const a=async e=>{const i=parseInt(await t(e));if(isNaN(i)){return 0}return i};const s={id:e.getAttribute("data-did"),username:await t(".main-content .user-name"),text:"",reposts:await a(".button-bar .single-button:nth-child(1) .text-offset"),comments:await a(".button-bar .single-button:nth-child(2) .text-offset"),likes:await a(".button-bar .single-button:nth-child(3) .text-offset"),element:e,type:n(e),async getText(){const e=await r(this.type);this.text=e;return e}};await s.getText();e.setAttribute("data-type",s.type.id.toString());return s}async startWatching(){const e=await SpinQuery.select(".card-list .content");if(!e){return false}if(this.watching){return true}this.watching=true;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 a=new r;const s=async(e="video")=>{if(!getUID()){return[]}const t=await Ajax.getJsonWithCredentials(`https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=${getUID()}&type_list=${e==="video"?8:512}`);if(t.code!==0){throw new Error(t.message)}if(e==="video"){return t.data.cards.filter(e=>{return e.desc.orig_dy_id===0}).map(e=>{const t=JSON.parse(e.card);const i=_.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:i,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:store.state.watchlaterList.includes(t.aid)}})}else if(e==="bangumi"){return t.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:a,feedsCardTypes:i,getVideoFeeds:s}}}})();

File diff suppressed because one or more lines are too long

View File

@ -53,6 +53,30 @@ export const feedsCardTypes = {
id: 2048,
name: '分享',
} as FeedsCardType,
manga: {
id: 2049,
name: '漫画',
} as FeedsCardType,
film: {
id: 4098,
name: '电影',
} as FeedsCardType,
tv: {
id: 4099,
name: 'TV剧',
} as FeedsCardType,
chinese: {
id: 4100,
name: '国创',
} as FeedsCardType,
documentary: {
id: 4101,
name: '纪录片',
} as FeedsCardType,
mediaList: {
id: 4300,
name: '收藏夹',
} as FeedsCardType,
}
export interface FeedsCard {
id: string

View File

@ -175,6 +175,10 @@ export default {
return
}
this.allTypes = Object.entries(feedsCardTypes)
.filter(([name, type]) => type.id <= 2048)
.map(([name, type]) => {
return [name, _.clone(type)]
})
feedsCardsManager.cards.forEach(card => this.updateCard(card))
feedsCardsManager.addEventListener('addCard', (e) => {
const card = e.detail

View File

@ -4,10 +4,15 @@
| 2^0 | 2^1 | 2^2 | 2^3 | 2^4 | 2^5 | 2^6 | 2^7 |
| 转发 | 图文 | 文字 | 投稿视频 | 小视频 | ??? | 专栏 | 无效 |
| 256 | 512 | 1024 | 2048 | 4098(不是4096) | 8192 | 16384 | 32768 |
| -------- | ---- | ---- | ---- | -------------- | ---- | ----- | ----- |
| 2^8 | 2^9 | 2^10 | 2^11 | 2^12 + 2 | 2^13 | 2^14 | 2^15 |
| 投稿音频 | 番剧 | ??? | 分享 | 电影 | 无效 | 无效 | 无效 |
| 256 | 512 | 1024 | 2048 | 2049 | 4098 | 4099 |
| -------- | ---- | ---- | ---- | -------- | -------- | -------- |
| 2^8 | 2^9 | 2^10 | 2^11 | 2^11 + 1 | 2^12 + 2 | 2^12 + 3 |
| 投稿音频 | 番剧 | 无效 | 分享 | 漫画 | 电影 | TV剧 |
| 4100 | 4101 | 4300 | 4302 | 4303 | 8192 | 16384 | 32768 |
| -------- | -------- | ------ | ---- | -------- | ---- | ----- | ----- |
| 2^12 + 4 | 2^12 + 5 | \ | \ | \ | 2^13 | 2^14 | 2^15 |
| 国创 | 纪录片 | 收藏夹 | 课程 | 课程更新 | 无效 | 无效 | 无效 |
| 65536 | 131072 | 262144 | 524288 | 1048576 | 2097152 | 4194304 | 8388608 |
| ----- | ------ | ------ | ------ | ------- | ------- | ------- | ------- |