support sync teleplay

This commit is contained in:
HughWan 2023-10-16 23:18:37 +08:00
parent 331ff38cd9
commit 405ae66da8
15 changed files with 122 additions and 9 deletions

@ -191,14 +191,25 @@ export enum SyncType {
broadcast = 'broadcast',
note = 'note',
music = 'music',
teleplay = 'teleplay'
}
export const SyncTypeUrlDomain: Map<SyncType, string> = new Map([
[SyncType.movie , 'movie'],
[SyncType.book , 'book'],
[SyncType.broadcast , 'broadcast'],
[SyncType.note , 'note'],
[SyncType.music , 'music'],
[SyncType.teleplay , 'movie']]
)
/**
*
*/
// @ts-ignore
export const SyncTypeRecords: { [key in SyncType]: string } = {
[SyncType.movie]: i18nHelper.getMessage('504103'),
[SyncType.teleplay]: i18nHelper.getMessage('504107'),
[SyncType.book]: i18nHelper.getMessage('504102'),
// [SyncType.broadcast]: i18nHelper.getMessage('504104'),
// [SyncType.note]: i18nHelper.getMessage('504105'),

@ -88,6 +88,15 @@ export const DoubanSubjectStateRecords_MOVIE_SYNC: { [key in DoubanSubjectState]
[DoubanSubjectState.collect]: i18nHelper.getMessage('500204'),
}
// @ts-ignore
export const DoubanSubjectStateRecords_TELEPLAY_SYNC: { [key in DoubanSubjectState]: string } = {
// @ts-ignore
[ALL]: i18nHelper.getMessage('500004'),
[DoubanSubjectState.wish]: i18nHelper.getMessage('500202'),
[DoubanSubjectState.do]: i18nHelper.getMessage('500203'),
[DoubanSubjectState.collect]: i18nHelper.getMessage('500204'),
}
// @ts-ignore
export const DoubanSubjectStateRecords_BOOK_SYNC: { [key in DoubanSubjectState]: string } = {
// @ts-ignore

@ -10,8 +10,12 @@ import HandleContext from "../data/model/HandleContext";
import {SyncType, SyncTypeRecords} from "../../constant/Constsant";
import {
ALL,
DoubanSubjectStateRecords_BOOK_SYNC, DoubanSubjectStateRecords_BROADCAST_SYNC,
DoubanSubjectStateRecords_MOVIE_SYNC, DoubanSubjectStateRecords_MUSIC_SYNC, DoubanSubjectStateRecords_NOTE_SYNC
DoubanSubjectStateRecords_BOOK_SYNC,
DoubanSubjectStateRecords_BROADCAST_SYNC,
DoubanSubjectStateRecords_MOVIE_SYNC,
DoubanSubjectStateRecords_MUSIC_SYNC,
DoubanSubjectStateRecords_NOTE_SYNC,
DoubanSubjectStateRecords_TELEPLAY_SYNC
} from "../../constant/DoubanUserState";
import {SyncConfig} from "../sync/model/SyncConfig";
import {clearInterval} from "timers";
@ -189,6 +193,10 @@ ${syncStatus.getHandle() == 0? '...' : i18nHelper.getMessage('110042') + ':' + T
case SyncType.music:
this.showScopeDropdown(contentEl, DoubanSubjectStateRecords_MUSIC_SYNC, config, disable);
break;
case SyncType.teleplay:
this.showScopeDropdown(contentEl, DoubanSubjectStateRecords_TELEPLAY_SYNC, config, disable);
break;
}
}
@ -225,6 +233,9 @@ ${syncStatus.getHandle() == 0? '...' : i18nHelper.getMessage('110042') + ':' + T
case SyncType.music:
result = (settings.musicTemplateFile == '' || settings.musicTemplateFile == null) ? DEFAULT_SETTINGS.musicTemplateFile : settings.musicTemplateFile
break;
case SyncType.teleplay:
result = (settings.teleplayTemplateFile == '' || settings.teleplayTemplateFile == null) ? DEFAULT_SETTINGS.teleplayTemplateFile : settings.teleplayTemplateFile
break;
}
return result;
}

@ -0,0 +1,28 @@
import {DoubanAbstractSyncHandler} from "./DoubanAbstractSyncHandler";
import {BasicConst, SyncType} from "../../../constant/Constsant";
import DoubanPlugin from "../../../main";
import DoubanTeleplaySubject from "../../data/model/DoubanTeleplaySubject";
import {DoubanTeleplayLoadHandler} from "../../data/handler/DoubanTeleplayLoadHandler";
import DoubanTeleplayCollectListHandler from "./list/DoubanTeleplayCollectListHandler";
import DoubanTeleplayWishListHandler from "./list/DoubanTeleplayWishListHandler";
import DoubanTeleplayDoListHandler from "./list/DoubanTeleplayDoListHandler";
//TODO will support in future version
export class DoubanTeleplaySyncHandler extends DoubanAbstractSyncHandler<DoubanTeleplaySubject>{
constructor(plugin:DoubanPlugin) {
super(plugin, new DoubanTeleplayLoadHandler(plugin),[
new DoubanTeleplayCollectListHandler(),
new DoubanTeleplayWishListHandler(),
new DoubanTeleplayDoListHandler()]);
}
getSyncType(): SyncType {
return SyncType.teleplay;
}
}

@ -8,6 +8,7 @@ import { DoubanMovieSyncHandler } from "./DoubanMovieSyncHandler";
import { DoubanMusicSyncHandler } from "./DoubanMusicSyncHandler";
import { DoubanBookSyncHandler } from "./DoubanBookSyncHandler";
import {i18nHelper} from "../../../lang/helper";
import {DoubanTeleplaySyncHandler} from "./DoubanTeleplaySyncHandler";
export default class SyncHandler {
private app: App;
@ -30,6 +31,7 @@ export default class SyncHandler {
// new DoubanBroadcastSyncHandler(plugin),
// new DoubanNoteSyncHandler(plugin),
new DoubanMusicSyncHandler(plugin),
new DoubanTeleplaySyncHandler(plugin),
this.defaultSyncHandler
];
}

@ -4,7 +4,7 @@ import {log} from "src/org/wanxp/utils/Logutil";
import {CheerioAPI, load} from "cheerio";
import HandleContext from "../../../data/model/HandleContext";
import {doubanSubjectSyncListUrl} from "../../../../constant/Douban";
import {BasicConst, PAGE_SIZE} from "../../../../constant/Constsant";
import {BasicConst, PAGE_SIZE, SyncType, SyncTypeUrlDomain} from "../../../../constant/Constsant";
import {SubjectListItem} from "../../../data/model/SubjectListItem";
import {DoubanListHandler} from "./DoubanListHandler";
import {SyncConfig} from "../../model/SyncConfig";
@ -38,12 +38,16 @@ export default abstract class DoubanAbstractListHandler implements DoubanListHan
}
private getUrl(context: HandleContext, start:number) {
return doubanSubjectSyncListUrl(this.getSyncType(), context.userComponent.getUserId(), this.getDoType(), start);
return doubanSubjectSyncListUrl(this.getSyncTypeDomain(), context.userComponent.getUserId(), this.getDoType(), start);
}
abstract getDoType():string;
abstract getSyncType():string;
abstract getSyncType():SyncType;
getSyncTypeDomain():string {
return SyncTypeUrlDomain.get(this.getSyncType());
}
async getPageList(url: string, context: HandleContext):Promise<SubjectListItem[]> {
return HttpUtil.httpRequestGet(url, context.plugin.settingsManager.getHeaders(), context.plugin.settingsManager)

@ -1,8 +1,8 @@
import DoubanAbstractListHandler from "./DoubanAbstractListHandler";
import { SyncType} from "../../../../constant/Constsant";
import {SyncType, SyncTypeUrlDomain} from "../../../../constant/Constsant";
export abstract class DoubanBookListHandler extends DoubanAbstractListHandler {
getSyncType(): string {
getSyncType(): SyncType {
return SyncType.book;
}

@ -2,7 +2,7 @@ import DoubanAbstractListHandler from "./DoubanAbstractListHandler";
import { SyncType} from "../../../../constant/Constsant";
export abstract class DoubanMovieListHandler extends DoubanAbstractListHandler {
getSyncType(): string {
getSyncType(): SyncType {
return SyncType.movie;
}

@ -2,7 +2,7 @@ import DoubanAbstractListHandler from "./DoubanAbstractListHandler";
import { SyncType} from "../../../../constant/Constsant";
export abstract class DoubanMusicListHandler extends DoubanAbstractListHandler {
getSyncType(): string {
getSyncType(): SyncType {
return SyncType.music;
}

@ -0,0 +1,11 @@
import { DoubanSubjectState} from "src/org/wanxp/constant/DoubanUserState";
import { DoubanMovieListHandler } from "./DoubanMovieListHandler";
import {DoubanTeleplayListHandler} from "./DoubanTeleplayListHandler";
export default class DoubanTeleplayCollectListHandler extends DoubanTeleplayListHandler{
getDoType(): string {
return DoubanSubjectState.collect;
}
}

@ -0,0 +1,11 @@
import { DoubanSubjectState} from "src/org/wanxp/constant/DoubanUserState";
import { DoubanMovieListHandler } from "./DoubanMovieListHandler";
import {DoubanTeleplayListHandler} from "./DoubanTeleplayListHandler";
export default class DoubanTeleplayDoListHandler extends DoubanTeleplayListHandler{
getDoType(): string {
return DoubanSubjectState.do;
}
}

@ -0,0 +1,13 @@
import DoubanAbstractListHandler from "./DoubanAbstractListHandler";
import { SyncType} from "../../../../constant/Constsant";
export abstract class DoubanTeleplayListHandler extends DoubanAbstractListHandler {
getSyncType(): SyncType {
return SyncType.teleplay;
}
abstract getDoType(): string;
}

@ -0,0 +1,11 @@
import { DoubanSubjectState} from "src/org/wanxp/constant/DoubanUserState";
import { DoubanMovieListHandler } from "./DoubanMovieListHandler";
import {DoubanTeleplayListHandler} from "./DoubanTeleplayListHandler";
export default class DoubanTeleplayWishListHandler extends DoubanTeleplayListHandler{
getDoType(): string {
return DoubanSubjectState.wish;
}
}

@ -538,6 +538,7 @@ PS: This file could be delete if you want to.
'500001': `Sync Config`,
'504102': `My Book`,
'504103': `My Movie`,
'504107': `My Teleplay`,
'504104': `My Broadcast`,
'504105': `My Note`,
'504106': `My Music`,

@ -549,6 +549,7 @@ export default {
'500001': `同步设置`,
'504102': `我的书籍`,
'504103': `我的电影`,
'504107': `我的电视剧`,
'504104': `我的广播`,
'504105': `我的日记`,
'504106': `我的音乐`,