@forward-widget/danmu-universe 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4187,9 +4187,10 @@ const getExternalIdsByTmdbId = async (e, t)=>{
4187
4187
  }
4188
4188
  case "youku":
4189
4189
  {
4190
- let { showid: e } = t.query;
4191
- e && (o.providers.youku = {
4192
- showId: e
4190
+ let { showid: e, vid: n } = t.query;
4191
+ (e || n) && (o.providers.youku = {
4192
+ showId: e,
4193
+ vid: n
4193
4194
  });
4194
4195
  break;
4195
4196
  }
@@ -5617,10 +5618,11 @@ function youku_define_property(e, t, n) {
5617
5618
  }) : e[t] = n, e;
5618
5619
  }
5619
5620
  const youkuIdSchema = schemas_object({
5620
- showId: schemas_string(),
5621
+ showId: schemas_string().optional(),
5621
5622
  vid: schemas_string().optional()
5622
5623
  }), youkuEpisodeInfoSchema = schemas_object({
5623
5624
  id: schemas_string(),
5625
+ show_id: schemas_string().optional(),
5624
5626
  title: schemas_string(),
5625
5627
  seq: schemas_string().transform((e)=>parseInt(e)).optional(),
5626
5628
  duration: schemas_string(),
@@ -5664,29 +5666,35 @@ class YoukuScraper extends BaseScraper {
5664
5666
  return null != (e = this.fetch.getCookie("cna")) ? e : "";
5665
5667
  }
5666
5668
  async getEpisodes(e, t) {
5667
- let n = this.parseIdString(e);
5668
- if (!n) return [];
5669
- let r = 20, i = null != t ? t : 1, o = Math.max(1, Math.ceil(i / 20));
5669
+ var n, r, i;
5670
+ let o = this.parseIdString(e);
5671
+ if (!o) return [];
5672
+ let s = o.showId;
5673
+ if (!s && o.vid) {
5674
+ let e = await this.getVideoInfo(o.vid);
5675
+ s = null != (n = null == e ? void 0 : e.show_id) ? n : "";
5676
+ }
5677
+ if (!s) return [];
5678
+ let a = 20, u = null != t ? t : 1, l = Math.max(1, Math.ceil(u / 20));
5670
5679
  try {
5671
- var s, a;
5672
- let e = (e)=>e.filter((e)=>!this.EPISODE_BLACKLIST_KEYWORDS.some((t)=>e.title.includes(t))), u = (e, t)=>({
5680
+ let e = (e)=>e.filter((e)=>!this.EPISODE_BLACKLIST_KEYWORDS.some((t)=>e.title.includes(t))), n = (e, t)=>({
5673
5681
  provider: this.providerName,
5674
5682
  episodeId: this.generateIdString({
5675
- showId: n.showId,
5683
+ showId: s,
5676
5684
  vid: e.id
5677
5685
  }),
5678
5686
  episodeTitle: e.title,
5679
5687
  episodeNumber: t
5680
- }), l = await this.getEpisodesPage(n.showId, o, r), c = e(null != (s = null == l ? void 0 : l.videos) ? s : []), d = c.find((e)=>e.seq === i);
5688
+ }), o = await this.getEpisodesPage(s, l, a), c = e(null != (r = null == o ? void 0 : o.videos) ? r : []), d = c.find((e)=>e.seq === u);
5681
5689
  if (d) return [
5682
- u(d, i)
5690
+ n(d, u)
5683
5691
  ];
5684
- let p = Number(null != (a = null == l ? void 0 : l.total) ? a : 0), f = Math.max(1, Math.ceil(p / r)), h = Array.from({
5692
+ let p = Number(null != (i = null == o ? void 0 : o.total) ? i : 0), f = Math.max(1, Math.ceil(p / a)), h = Array.from({
5685
5693
  length: f
5686
- }, (e, t)=>t + 1).filter((e)=>e !== o), m = [];
5694
+ }, (e, t)=>t + 1).filter((e)=>e !== l), m = [];
5687
5695
  for (let e of h){
5688
5696
  await this.sleep(500);
5689
- let t = await this.getEpisodesPage(n.showId, e, r);
5697
+ let t = await this.getEpisodesPage(s, e, a);
5690
5698
  m.push(t);
5691
5699
  }
5692
5700
  let g = e(m.flatMap((e)=>{
@@ -5697,17 +5705,17 @@ class YoukuScraper extends BaseScraper {
5697
5705
  ...g
5698
5706
  ];
5699
5707
  if (void 0 !== t) {
5700
- let e = v.find((e)=>e.seq === i);
5708
+ let e = v.find((e)=>e.seq === u);
5701
5709
  return e ? [
5702
- u(e, i)
5710
+ n(e, u)
5703
5711
  ] : [];
5704
5712
  }
5705
5713
  return v.sort((e, t)=>{
5706
5714
  var n, r;
5707
5715
  return (null != (n = e.seq) ? n : Number.MAX_SAFE_INTEGER) - (null != (r = t.seq) ? r : Number.MAX_SAFE_INTEGER);
5708
- }).map((e, t)=>u(e, t + 1));
5716
+ }).map((e, t)=>n(e, t + 1));
5709
5717
  } catch (e) {
5710
- return console.error(`Youku: \u{83B7}\u{53D6}\u{5206}\u{96C6}\u{5931}\u{8D25} showId=${n.showId}:`, e), [];
5718
+ return console.error(`Youku: \u{83B7}\u{53D6}\u{5206}\u{96C6}\u{5931}\u{8D25} showId=${s}:`, e), [];
5711
5719
  }
5712
5720
  }
5713
5721
  async getSegments(e) {
@@ -5716,17 +5724,7 @@ class YoukuScraper extends BaseScraper {
5716
5724
  if (!n) return [];
5717
5725
  try {
5718
5726
  await this.ensureTokenCookie();
5719
- let e = (await this.fetch.get("https://openapi.youku.com/v2/videos/show_basic.json", {
5720
- params: {
5721
- client_id: "53e6cc67237fc59a",
5722
- package: "com.huawei.hwvplayer.youku",
5723
- video_id: n
5724
- },
5725
- schema: youkuEpisodeInfoSchema,
5726
- cache: {
5727
- cacheKey: `youku:segments:${n}`
5728
- }
5729
- })).data;
5727
+ let e = await this.getVideoInfo(n);
5730
5728
  if (!e) return console.warn(`Youku: Failed to get episode info for vid ${n}`), [];
5731
5729
  let t = e.totalMat;
5732
5730
  if (0 === t) return console.warn(`Youku: Video ${n} has duration 0, no danmaku to fetch.`), [];
@@ -5751,6 +5749,19 @@ class YoukuScraper extends BaseScraper {
5751
5749
  return console.error(`Youku: Failed to get danmaku for vid ${r}:`, e), [];
5752
5750
  }
5753
5751
  }
5752
+ async getVideoInfo(e) {
5753
+ return (await this.fetch.get("https://openapi.youku.com/v2/videos/show_basic.json", {
5754
+ params: {
5755
+ client_id: "53e6cc67237fc59a",
5756
+ package: "com.huawei.hwvplayer.youku",
5757
+ video_id: e
5758
+ },
5759
+ schema: youkuEpisodeInfoSchema,
5760
+ cache: {
5761
+ cacheKey: `youku:segments:${e}`
5762
+ }
5763
+ })).data;
5764
+ }
5754
5765
  async getEpisodesPage(e, t, n) {
5755
5766
  return (await this.fetch.get("https://openapi.youku.com/v2/shows/videos.json", {
5756
5767
  params: {
@@ -6008,7 +6019,7 @@ WidgetMetadata = {
6008
6019
  title: "\u901A\u7528\u5F39\u5E55",
6009
6020
  description: "\u901A\u7528\u5F39\u5E55\u63D2\u4EF6\uFF0C\u652F\u6301\u817E\u8BAF\u3001\u4F18\u9177\u3001\u7231\u5947\u827A\u3001\u54D4\u54E9\u54D4\u54E9\u7B49\u5E73\u53F0",
6010
6021
  author: "Baran",
6011
- version: "0.0.6",
6022
+ version: "0.0.7",
6012
6023
  site: "https://github.com/baranwang/forward-widgets/tree/main/packages/danmu-universe",
6013
6024
  requiredVersion: "0.0.2",
6014
6025
  modules: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forward-widget/danmu-universe",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "main": "./dist/danmu-universe.js",
6
6
  "exports": {