Skip to content

Commit

Permalink
t3 module re-weight
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiram committed Mar 28, 2024
1 parent 76543a0 commit fd9f41a
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 51 deletions.
11 changes: 2 additions & 9 deletions src/renderer/src/pages/Film.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ import { onMounted, reactive, ref } from 'vue';
import { usePlayStore } from '@/store';
import { fetchSiteActive } from '@/api/site';
import { fetchClassify, fetchList, fetchSearch, fetchDetail, t3RuleInit, t3RuleTerminate, catvodRuleInit } from '@/utils/cms';
import { getConfig } from '@/utils/tool';
import DetailView from './film/Detail.vue';
import CommonNav from '../components/common-nav/index.vue';
Expand Down Expand Up @@ -449,11 +448,6 @@ const getFilmList = async () => {
}
};
const getContent = async(url: string) => {
const res = await getConfig(url);
return res;
}
// 加载
const load = async ($state: { complete: () => void; loaded: () => void; error: () => void }) => {
console.log('[film] loading...');
Expand All @@ -466,9 +460,8 @@ const load = async ($state: { complete: () => void; loaded: () => void; error: (
const defaultSite = siteConfig.value.default;
if (defaultSite.type === 7 && !isVisible.t3Work) {
const content = await getContent(defaultSite.ext);
const status = await t3RuleInit(content);
if (status === 'sucess') isVisible.t3Work = true;
const res = await t3RuleInit(defaultSite);
if (res.code === 200) isVisible.t3Work = true;
else $state.error();
} else if (defaultSite.type === 8 && !isVisible.catvodWork) {
const content = await catvodRuleInit(defaultSite.api, defaultSite.ext ? JSON.parse(defaultSite.ext) : {});
Expand Down
17 changes: 3 additions & 14 deletions src/renderer/src/pages/Play.vue
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ const getAnalysisData = async () => {
if (_.has(res, 'default')) analyzeConfig.value.default = res.default;
if (_.has(res, 'flag')) analyzeConfig.value.flag = res.flag;
console.log(`[analyze] jx:${res.default.url}; flag:${[...res.flag]}`);
// console.log(`[analyze] jx:${res.default.url}; flag:${[...res.flag]}`);
} catch (error) {
console.error(error);
}
Expand Down Expand Up @@ -1022,9 +1022,8 @@ const initFilmPlayer = async (isFirst) => {
// t3获取服务端播放链接
console.log('[player] start: t3获取服务端播放链接开启');
try {
const content = await getConfig(ext.value.site.ext);
const status = await t3RuleInit(content);
if (status === 'sucess') {
const res = await t3RuleInit(ext.value.site);
if (res.code === 200) {
const t3PlayUrl = await fetchT3PlayUrl(selectPlaySource.value, config.value.url , []);
config.value.url = t3PlayUrl.url;
}
Expand Down Expand Up @@ -1437,16 +1436,6 @@ const timerUpdatePlayProcess = () => {
xg.value.on(Events.ENDED, () => {
onEnded();
});
} else if (set.value.broadcasterType === 'tcplayer') {
tc.value.on('timeupdate', () => {
const duration = tc.value.duration();
const currentTime = tc.value.currentTime();
onTimeUpdate(currentTime, duration);
});
tc.value.on('ended', () => {
onEnded();
});
} else if (set.value.broadcasterType === 'dplayer') {
dp.value.on('timeupdate', () => {
const duration = dp.value.video.duration;
Expand Down
13 changes: 4 additions & 9 deletions src/renderer/src/pages/chase/binge/Binge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ import { ref, reactive } from 'vue';
import { fetchStarList, delStar } from '@/api/star';
import { fetchFilmDetail, fetchSiteList } from '@/api/site';
import { fetchDetail, t3RuleInit } from '@/utils/cms';
import { getConfig } from '@/utils/tool';
import { usePlayStore } from '@/store';
import DetailView from '../../film/Detail.vue';
Expand Down Expand Up @@ -162,20 +161,15 @@ const load = async ($state) => {
}
};
const getContent = async(url: string) => {
const res = await getConfig(url);
return res;
}
// 播放
const playEvent = async (item) => {
try {
const { videoName, relateId, videoId } = item;
const site = siteConfig.value.data.find(({ id }) => id === item.relateId);
siteData.value = site;
if (site.type === 7) {
const content = await getContent(site.ext);
const status = await t3RuleInit(content);
const res = await t3RuleInit(site);
if (res.data === 500) ;
}
if (!('vod_play_from' in item && 'vod_play_url' in item)) {
const [detailItem] = await fetchDetail(site, videoId);
Expand Down Expand Up @@ -224,7 +218,8 @@ const updateVideoRemarks = (item, res) => {
const checkUpdaterEvent = async () => {
const fetchAndUpdateVideoRemarks = async (item) => {
if (item.siteName = '该源应该被删除了哦') return;
console.log(item)
if (item.siteName === '该源应该被删除了哦') return;
const { site, videoId } = item;
try {
const [res] = await fetchDetail(site, videoId);
Expand Down
9 changes: 1 addition & 8 deletions src/renderer/src/pages/chase/history/History.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ import { ref, reactive } from 'vue';
import { delHistory, fetchHistoryList } from '@/api/history';
import { fetchSiteList } from '@/api/site';
import { fetchDetail, t3RuleInit } from '@/utils/cms';
import { getConfig } from '@/utils/tool';
import { usePlayStore } from '@/store';
import DetailView from '../../film/Detail.vue';
Expand Down Expand Up @@ -177,20 +176,14 @@ const load = async ($state) => {
}
};
const getContent = async(url: string) => {
const res = await getConfig(url);
return res;
}
// 播放
const playEvent = async (item) => {
try {
const { videoName, relateId, videoId } = item;
const site = siteConfig.value.data.find(({ id }) => id === item.relateId);
siteData.value = site;
if (site.type === 7) {
const content = await getContent(site.ext);
const status = await t3RuleInit(content);
const res = await t3RuleInit(site);
}
if (!('vod_play_from' in item && 'vod_play_url' in item)) {
const [detailItem] = await fetchDetail(site, videoId);
Expand Down
25 changes: 21 additions & 4 deletions src/renderer/src/utils/cms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,27 @@ const removeHTMLTagsAndSpaces = (str) => {
return trimmedString;
};

const t3RuleInit = async(rule: string) => {
const res: any = await t3Work({type:'init', data: rule});
return res.data;
const t3RuleInit = async(site) => {
let data = {
code: 500,
msg: 'site parameter not have ext or ext is empty',
};

if (_.has(site, 'ext')) {
try {
const res = await axios.get(site.ext);
const rule = res.data;
await t3Work({type:'init', data: rule});
data = {
code: 200,
msg: 'sucess'
}
} catch (err) {
data.msg = err as string;
}
}

return data;
}

const t3RuleTerminate = async() => {
Expand Down Expand Up @@ -846,7 +864,6 @@ const fetchCatvodPlayUrl = async (site, flag: string, id: string) => {
try {
const url = buildUrl(site.api, `/play`);
const res = await axios.post(url, {flag, id});
console.log(res)
return res.data;
} catch (err) {
throw err;
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/utils/drpy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const terminateWork = () => {
} else {
reject({
msg: new Error('Worker is not defined or already terminated.'),
code: 200
code: 500
});
}
});
Expand Down
7 changes: 1 addition & 6 deletions src/renderer/src/utils/drpy/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ const drpyWork = (parms) => {
let res = { type, data };
switch (type) {
case 'init':
try {
init(data);
res.data = 'sucess';
} catch(_){
res.data = 'error';
}
res.data = init(data);
break;
case 'home':
res.data = home();
Expand Down

0 comments on commit fd9f41a

Please sign in to comment.