rsshub 1.0.0-master.e4deee0 → 1.0.0-master.e4eedac

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.
Files changed (34) hide show
  1. package/lib/routes/aibase/news.ts +118 -0
  2. package/lib/routes/aibase/util.ts +3 -0
  3. package/lib/routes/bilibili/video.ts +1 -1
  4. package/lib/routes/cisia/index.ts +264 -0
  5. package/lib/routes/cisia/namespace.ts +8 -0
  6. package/lib/routes/cjlu/namespace.ts +10 -0
  7. package/lib/routes/cjlu/yjsy/index.ts +107 -0
  8. package/lib/routes/damai/activity.ts +3 -2
  9. package/lib/routes/famitsu/category.ts +1 -1
  10. package/lib/routes/hex-rays/index.ts +23 -29
  11. package/lib/routes/hfut/hf/notice.ts +43 -0
  12. package/lib/routes/hfut/hf/utils.ts +80 -0
  13. package/lib/routes/hfut/namespace.ts +6 -0
  14. package/lib/routes/hfut/xc/notice.ts +43 -0
  15. package/lib/routes/hfut/xc/utils.ts +73 -0
  16. package/lib/routes/hko/earthquake.ts +56 -0
  17. package/lib/routes/hko/namespace.ts +8 -0
  18. package/lib/routes/hko/weather.ts +56 -0
  19. package/lib/routes/papers/index.ts +7 -1
  20. package/lib/routes/parliament.uk/commonslibrary.ts +4 -4
  21. package/lib/routes/parliament.uk/lordslibrary.ts +4 -4
  22. package/lib/routes/picuki/profile.ts +50 -39
  23. package/lib/routes/rsshub/transform/html.ts +114 -75
  24. package/lib/routes/skeb/following-creators.ts +1 -1
  25. package/lib/routes/skeb/following-works.ts +1 -1
  26. package/lib/routes/skeb/friend-works.ts +1 -1
  27. package/lib/routes/skeb/index.ts +2 -2
  28. package/lib/routes/skeb/search.ts +1 -1
  29. package/lib/routes/skeb/works.ts +1 -1
  30. package/lib/routes/twitter/api/web-api/utils.ts +5 -3
  31. package/lib/routes/weibo/user.ts +1 -1
  32. package/lib/routes/zaobao/util.ts +41 -43
  33. package/package.json +8 -8
  34. package/lib/routes-deprecated/hko/weather.js +0 -44
@@ -0,0 +1,43 @@
1
+ import { Route } from '@/types';
2
+ import parseList from './utils';
3
+
4
+ export const route: Route = {
5
+ path: '/hf/notice/:type?',
6
+ categories: ['university'],
7
+ example: '/hfut/hf/notice/tzgg',
8
+ parameters: { type: '分类,见下表(默认为 `tzgg`)' },
9
+ features: {
10
+ requireConfig: false,
11
+ requirePuppeteer: false,
12
+ antiCrawler: false,
13
+ supportBT: false,
14
+ supportPodcast: false,
15
+ supportRadar: true,
16
+ supportScihub: false,
17
+ },
18
+ radar: [
19
+ {
20
+ source: ['news.hfut.edu.cn'],
21
+ },
22
+ ],
23
+ name: '合肥校区通知',
24
+ maintainers: ['batemax'],
25
+ handler,
26
+ description: `| 通知公告(https://news.hfut.edu.cn/tzgg2.htm) | 教学科研(https://news.hfut.edu.cn/tzgg2/jxky.htm) | 其他通知(https://news.hfut.edu.cn/tzgg2/qttz.htm) |
27
+ | ------------ | -------------- | ------------------ |
28
+ | tzgg | jxky | qttz |`,
29
+ };
30
+
31
+ async function handler(ctx) {
32
+ // set default router type
33
+ const type = ctx.req.param('type') ?? 'tzgg';
34
+
35
+ const { link, title, resultList } = await parseList(ctx, type);
36
+
37
+ return {
38
+ title,
39
+ link,
40
+ description: '合肥工业大学 - 通知公告',
41
+ item: resultList,
42
+ };
43
+ }
@@ -0,0 +1,80 @@
1
+ import cache from '@/utils/cache';
2
+ import got from '@/utils/got';
3
+ import { load } from 'cheerio';
4
+ import { parseDate } from '@/utils/parse-date';
5
+
6
+ const typeMap = {
7
+ tzgg: { name: 'tzgg', url: 'https://news.hfut.edu.cn/tzgg2.htm', root: 'https://news.hfut.edu.cn', title: '合肥工业大学 - 通知公告' },
8
+ jxky: { name: 'jxky', url: 'https://news.hfut.edu.cn/tzgg2.htm', root: 'https://news.hfut.edu.cn', title: '合肥工业大学 - 通知公告 - 教学科研' },
9
+ qttz: { name: 'qttz', url: 'https://news.hfut.edu.cn/tzgg2.htm', root: 'https://news.hfut.edu.cn', title: '合肥工业大学 - 通知公告 - 其它通知' },
10
+ };
11
+
12
+ const commLink = 'https://news.hfut.edu.cn/';
13
+
14
+ const parseList = async (ctx, type) => {
15
+ const link = typeMap[type].url;
16
+ const title = typeMap[type].title;
17
+
18
+ const response = await got(link);
19
+ const $ = load(response.data);
20
+
21
+ const resultList = await parseArticle(typeMap[type].name, $);
22
+
23
+ return {
24
+ title,
25
+ link,
26
+ resultList,
27
+ };
28
+ };
29
+
30
+ async function parseArticle(type, $) {
31
+ let data = $('#tzz').find('li').toArray();
32
+
33
+ if (type === 'jxky') {
34
+ data = $('#c01').find('li').toArray();
35
+ } else if (type === 'qttz') {
36
+ data = $('#c02').find('li').toArray();
37
+ }
38
+
39
+ const items = data.map((item) => {
40
+ item = $(item);
41
+ const oriLink = item.find('a').attr('href');
42
+ let linkRes = oriLink;
43
+ if (!oriLink.startsWith('http')) {
44
+ linkRes = commLink + item.find('a').attr('href');
45
+ }
46
+ const pubDate = parseDate(item.find('i').text(), 'YYYY-MM-DD');
47
+
48
+ return {
49
+ title: item.find('p').text(),
50
+ pubDate,
51
+ link: linkRes,
52
+ };
53
+ });
54
+
55
+ const resultItems = await Promise.all(
56
+ items.map((item) =>
57
+ cache.tryGet(item.link, async () => {
58
+ let description;
59
+ try {
60
+ const response = await got(item.link);
61
+ const $ = load(response.data);
62
+ description = $('.wp_articlecontent').html() ?? $('.v_news_content').html() ?? item.link;
63
+ } catch {
64
+ description = item.link;
65
+ }
66
+
67
+ return {
68
+ title: item.title,
69
+ link: item.link,
70
+ description,
71
+ pubDate: item.pubDate,
72
+ };
73
+ })
74
+ )
75
+ );
76
+
77
+ return resultItems;
78
+ }
79
+
80
+ export default parseList;
@@ -0,0 +1,6 @@
1
+ import type { Namespace } from '@/types';
2
+
3
+ export const namespace: Namespace = {
4
+ name: '合肥工业大学',
5
+ url: 'hfut.edu.cn',
6
+ };
@@ -0,0 +1,43 @@
1
+ import { Route } from '@/types';
2
+ import parseList from './utils';
3
+
4
+ export const route: Route = {
5
+ path: '/xc/notice/:type?',
6
+ categories: ['university'],
7
+ example: '/hfut/xc/notice/tzgg',
8
+ parameters: { type: '分类,见下表(默认为 `tzgg`)' },
9
+ features: {
10
+ requireConfig: false,
11
+ requirePuppeteer: false,
12
+ antiCrawler: false,
13
+ supportBT: false,
14
+ supportPodcast: false,
15
+ supportRadar: true,
16
+ supportScihub: false,
17
+ },
18
+ radar: [
19
+ {
20
+ source: ['xc.hfut.edu.cn'],
21
+ },
22
+ ],
23
+ name: '宣城校区通知',
24
+ maintainers: ['batemax'],
25
+ handler,
26
+ description: `| 通知公告(https://xc.hfut.edu.cn/1955/list.htm) | 院系动态-工作通知(https://xc.hfut.edu.cn/gztz/list.htm) |
27
+ | ------------ | -------------- |
28
+ | tzgg | gztz |`,
29
+ };
30
+
31
+ async function handler(ctx) {
32
+ // set default router type
33
+ const type = ctx.req.param('type') ?? 'tzgg';
34
+
35
+ const { link, title, resultList } = await parseList(ctx, type);
36
+
37
+ return {
38
+ title,
39
+ link,
40
+ description: '合肥工业大学宣城校区 - 通知公告',
41
+ item: resultList,
42
+ };
43
+ }
@@ -0,0 +1,73 @@
1
+ import cache from '@/utils/cache';
2
+ import got from '@/utils/got';
3
+ import { load } from 'cheerio';
4
+ import { parseDate } from '@/utils/parse-date';
5
+
6
+ const typeMap = {
7
+ tzgg: { name: 'tzgg', url: 'https://xc.hfut.edu.cn/1955/list.htm', root: 'https://xc.hfut.edu.cn', title: '合肥工业大学宣城校区 - 通知公告' },
8
+ gztz: { name: 'gztz', url: 'https://xc.hfut.edu.cn/gztz/list.htm', root: 'https://xc.hfut.edu.cn', title: '合肥工业大学宣城校区 - 院系动态 - 工作通知' },
9
+ };
10
+
11
+ const commLink = 'https://xc.hfut.edu.cn/';
12
+
13
+ const parseList = async (ctx, type) => {
14
+ const link = typeMap[type].url;
15
+ const title = typeMap[type].title;
16
+
17
+ const response = await got(link);
18
+ const $ = load(response.data);
19
+
20
+ const resultList = await parseArticle($);
21
+
22
+ return {
23
+ title,
24
+ link,
25
+ resultList,
26
+ };
27
+ };
28
+
29
+ async function parseArticle($) {
30
+ const data = $('#wp_news_w6').find('li').toArray();
31
+
32
+ const items = data.map((item) => {
33
+ item = $(item);
34
+ const oriLink = item.find('a').attr('href');
35
+ let linkRes = oriLink;
36
+ if (!oriLink.startsWith('http')) {
37
+ linkRes = commLink + item.find('a').attr('href');
38
+ }
39
+ const pubDate = parseDate(item.find('.news_meta').text(), 'YYYY-MM-DD');
40
+
41
+ return {
42
+ title: item.find('a').attr('title'),
43
+ pubDate,
44
+ link: linkRes,
45
+ };
46
+ });
47
+
48
+ const resultItems = await Promise.all(
49
+ items.map((item) =>
50
+ cache.tryGet(item.link, async () => {
51
+ let description;
52
+ try {
53
+ const response = await got(item.link);
54
+ const $ = load(response.data);
55
+ description = $('.wp_articlecontent').html() ?? $('.v_news_content').html() ?? item.link;
56
+ } catch {
57
+ description = item.link;
58
+ }
59
+
60
+ return {
61
+ title: item.title,
62
+ link: item.link,
63
+ description,
64
+ pubDate: item.pubDate,
65
+ };
66
+ })
67
+ )
68
+ );
69
+
70
+ return resultItems;
71
+ }
72
+
73
+ export default parseList;
@@ -0,0 +1,56 @@
1
+ import { Route } from '@/types';
2
+ import ofetch from '@/utils/ofetch';
3
+ import { load } from 'cheerio';
4
+ import { parseDate } from '@/utils/parse-date';
5
+ import timezone from '@/utils/timezone';
6
+
7
+ export const route: Route = {
8
+ path: '/earthquake',
9
+ name: '全球地震資訊網',
10
+ maintainers: ['after9'],
11
+ handler,
12
+ example: '/hko/earthquake',
13
+ categories: ['forecast'],
14
+ description: '来自香港天文台的全球5级以上地震记录',
15
+ };
16
+
17
+ async function handler() {
18
+ const title = '来自香港天文台的全球5级以上地震记录';
19
+ const link = 'https://www.hko.gov.hk/tc/gts/equake/quake-info.htm';
20
+ const description = '提供經天文台分析的全球5.0級或以上及本地有感的地震資訊。';
21
+
22
+ // 发送 HTTP GET 请求到 API 并解构返回的数据对象
23
+ const response = await ofetch('https://www.hko.gov.hk/gts/QEM/eq_app-30d_uc.xml', {
24
+ headers: {
25
+ accept: 'application/xml',
26
+ },
27
+ });
28
+
29
+ const $ = load(response);
30
+
31
+ const items = $('Earthquake > EventGroup > Event')
32
+ // 使用“toArray()”方法将选择的所有 DOM 元素以数组的形式返回。
33
+ .toArray()
34
+ // 使用“map()”方法遍历数组,并从每个元素中解析需要的数据。
35
+ .map((item) => {
36
+ item = $(item);
37
+ const degree = item.find('Mag').text();
38
+ const city = item.find('City').text();
39
+ const citystring = item.find('citystring').text();
40
+ const hktDate = item.find('HKTDate').text();
41
+ const hktTime = item.find('HKTTime').text();
42
+ const latAndLon = '經緯:[' + item.find('Lat').text() + ',' + item.find('Lon').text() + ']';
43
+ return {
44
+ title: `[震級:${degree}] [地點:${city}]`,
45
+ description: `${citystring}, ${latAndLon}`,
46
+ pubDate: timezone(parseDate(hktDate + hktTime, 'YYYYMMDDHHMM'), +8),
47
+ };
48
+ });
49
+
50
+ return {
51
+ title,
52
+ link,
53
+ description,
54
+ item: items,
55
+ };
56
+ }
@@ -0,0 +1,8 @@
1
+ import type { Namespace } from '@/types';
2
+
3
+ export const namespace: Namespace = {
4
+ name: 'Hong Kong Observatory',
5
+ url: 'www.hko.gov.hk',
6
+ categories: ['forecast'],
7
+ description: '来自香港天文台的全球地震记录',
8
+ };
@@ -0,0 +1,56 @@
1
+ import type { Route } from '@/types';
2
+ import ofetch from '@/utils/ofetch';
3
+ import * as cheerio from 'cheerio';
4
+ import { parseDate } from '@/utils/parse-date';
5
+
6
+ const handler = async () => {
7
+ const url = 'http://rss.weather.gov.hk/rss/CurrentWeather.xml';
8
+ const pageUrl = 'https://www.weather.gov.hk/en/wxinfo/currwx/current.htm';
9
+
10
+ const data = await ofetch(url);
11
+ const $ = cheerio.load(data, {
12
+ xmlMode: true,
13
+ });
14
+
15
+ const description = $('item').first().find('description');
16
+
17
+ const $$ = cheerio.load(description.text());
18
+
19
+ const items = $$('table tr')
20
+ .toArray()
21
+ .map((item) => {
22
+ const $item = $(item);
23
+ const area = $item.find('td').first().text();
24
+ const degree = $item.find('td').last().text();
25
+
26
+ return {
27
+ title: area,
28
+ description: degree,
29
+ pubDate: parseDate($('pubDate').text()),
30
+ link: pageUrl,
31
+ guid: `${$('guid').text()}#${area}`,
32
+ };
33
+ });
34
+
35
+ return {
36
+ title: 'Current Weather Report',
37
+ description: `provided by the Hong Kong Observatory: ${$('pubDate').text()}`,
38
+ link: pageUrl,
39
+ item: items,
40
+ };
41
+ };
42
+
43
+ export const route: Route = {
44
+ path: '/weather',
45
+ radar: [
46
+ {
47
+ source: ['www.weather.gov.hk/en/wxinfo/currwx/current.htm'],
48
+ },
49
+ ],
50
+ name: 'Current Weather Report',
51
+ example: '/hko/weather',
52
+ maintainers: ['calpa'],
53
+ categories: ['forecast'],
54
+ handler,
55
+ url: 'www.weather.gov.hk/en/wxinfo/currwx/current.htm',
56
+ };
@@ -20,7 +20,7 @@ export const handler = async (ctx) => {
20
20
  const feedUrl = new URL(`${category}/feed`, rootUrl).href;
21
21
 
22
22
  const site = category.split(/\//)[0];
23
- const apiKimiUrl = new URL(`${site}/kimi/`, rootUrl).href;
23
+ const apiKimiUrl = new URL(`${site}/kimi?paper=`, rootUrl).href;
24
24
 
25
25
  const feed = await parser.parseURL(feedUrl);
26
26
 
@@ -91,6 +91,7 @@ export const route: Route = {
91
91
  | arXiv Computation and Language (cs.CL) | arxiv/cs.CL |
92
92
  | arXiv Computer Vision and Pattern Recognition (cs.CV) | arxiv/cs.CV |
93
93
  | arXiv Machine Learning (cs.LG) | arxiv/cs.LG |
94
+ | arXiv Robotics (cs.RO) | arxiv/cs.RO |
94
95
  `,
95
96
  categories: ['journal'],
96
97
 
@@ -124,5 +125,10 @@ export const route: Route = {
124
125
  source: ['papers.cool/arxiv/cs.LG'],
125
126
  target: '/arxiv/cs.LG',
126
127
  },
128
+ {
129
+ title: 'arXiv Robotics (cs.RO)',
130
+ source: ['papers.cool/arxiv/cs.RO'],
131
+ target: '/arxiv/cs.RO',
132
+ },
127
133
  ],
128
134
  };
@@ -23,8 +23,8 @@ export const route: Route = {
23
23
 
24
24
  async function handler(ctx) {
25
25
  const { topic } = ctx.req.param();
26
- const baseUrl = 'https://commonslibrary.parliament.uk/type';
27
- const url = `${baseUrl}/${topic}/`;
26
+ const baseUrl = 'https://commonslibrary.parliament.uk';
27
+ const url = `${baseUrl}/type/${topic}/`;
28
28
  const browser = await puppeteer();
29
29
  const page = await browser.newPage();
30
30
  await page.setRequestInterception(true);
@@ -38,7 +38,7 @@ async function handler(ctx) {
38
38
  const html = await page.evaluate(() => document.documentElement.innerHTML);
39
39
  await page.close();
40
40
  const $ = load(html);
41
- const items = $('article.card--horizontal')
41
+ const items = $('div.l-box.l-box--no-border.card__text')
42
42
  .map((_, article) => ({
43
43
  title: $(article).find('.card__text a').text().trim(),
44
44
  link: $(article).find('.card__text a').attr('href'),
@@ -49,7 +49,7 @@ async function handler(ctx) {
49
49
  browser.close();
50
50
  return {
51
51
  title: `parliament - lordslibrary - ${topic}`,
52
- link: baseUrl,
52
+ link: url,
53
53
  item: items,
54
54
  };
55
55
  }
@@ -23,8 +23,8 @@ export const route: Route = {
23
23
 
24
24
  async function handler(ctx) {
25
25
  const { topic } = ctx.req.param();
26
- const baseUrl = 'https://lordslibrary.parliament.uk/type';
27
- const url = `${baseUrl}/${topic}/`;
26
+ const baseUrl = 'https://lordslibrary.parliament.uk';
27
+ const url = `${baseUrl}/type/${topic}/`;
28
28
  const browser = await puppeteer();
29
29
  const page = await browser.newPage();
30
30
  await page.setRequestInterception(true);
@@ -38,7 +38,7 @@ async function handler(ctx) {
38
38
  const html = await page.evaluate(() => document.documentElement.innerHTML);
39
39
  await page.close();
40
40
  const $ = load(html);
41
- const items = $('article.card--horizontal')
41
+ const items = $('div.l-box.l-box--no-border.card__text')
42
42
  .map((_, article) => ({
43
43
  title: $(article).find('.card__text a').text().trim(),
44
44
  link: $(article).find('.card__text a').attr('href'),
@@ -49,7 +49,7 @@ async function handler(ctx) {
49
49
  browser.close();
50
50
  return {
51
51
  title: `parliament - lordslibrary - ${topic}`,
52
- link: baseUrl,
52
+ link: url,
53
53
  item: items,
54
54
  };
55
55
  }
@@ -1,4 +1,4 @@
1
- import { Route } from '@/types';
1
+ import { DataItem, Route } from '@/types';
2
2
  import { getCurrentPath } from '@/utils/helpers';
3
3
  const __dirname = getCurrentPath(import.meta.url);
4
4
 
@@ -16,20 +16,29 @@ function deVideo(media) {
16
16
  let media_deVideo = '';
17
17
  $('img,video').each((_, medium) => {
18
18
  const tag = medium.name;
19
- medium = $(medium);
20
- const poster = medium.attr('poster');
19
+ const mediumElement = $(medium);
20
+ const poster = mediumElement.attr('poster');
21
21
  // 如果有 poster 属性,表明它是视频,将它替换为它的 poster;如果不是,就原样返回
22
- media_deVideo += poster ? `<img src='${poster}' alt='video poster'>` : tag === 'img' ? medium.toString() : '';
22
+ media_deVideo += (() => {
23
+ if (poster) {
24
+ return `<img src='${poster}' alt='video poster'>`;
25
+ } else if (tag === 'img') {
26
+ return mediumElement.toString();
27
+ } else {
28
+ return '';
29
+ }
30
+ })();
23
31
  });
24
32
  return media_deVideo;
25
33
  }
26
34
 
27
35
  export const route: Route = {
28
- path: '/profile/:id/:functionalFlag?',
36
+ path: '/profile/:id/:type?/:functionalFlag?',
29
37
  categories: ['social-media'],
30
38
  example: '/picuki/profile/stefaniejoosten',
31
39
  parameters: {
32
40
  id: 'Instagram user id',
41
+ type: 'Type of profile page (profile or tagged)',
33
42
  functionalFlag: `functional flag, see the table below
34
43
  | functionalFlag | Video embedding | Fetching Instagram Stories |
35
44
  | -------------- | --------------------------------------- | -------------------------- |
@@ -51,9 +60,13 @@ export const route: Route = {
51
60
  source: ['www.picuki.com/profile/:id'],
52
61
  target: '/profile/:id',
53
62
  },
63
+ {
64
+ source: ['www.picuki.com/profile-tagged/:id'],
65
+ target: '/profile/:id/tagged',
66
+ },
54
67
  ],
55
68
  name: 'User Profile - Picuki',
56
- maintainers: ['hoilc', 'Rongronggg9', 'devinmugen'],
69
+ maintainers: ['hoilc', 'Rongronggg9', 'devinmugen', 'NekoAria'],
57
70
  handler,
58
71
  description: `
59
72
  :::warning
@@ -67,61 +80,58 @@ async function handler(ctx) {
67
80
  const browser = await puppeteer();
68
81
 
69
82
  const id = ctx.req.param('id');
70
- const displayVideo = ctx.req.param('functionalFlag') !== '0';
71
- const includeStories = ctx.req.param('functionalFlag') === '10';
83
+ const type = ctx.req.param('type') ?? 'profile';
84
+ const functionalFlag = ctx.req.param('functionalFlag') ?? '1';
85
+ const displayVideo = functionalFlag !== '0';
86
+ const includeStories = functionalFlag === '10';
72
87
 
73
- const profileUrl = `https://www.picuki.com/profile/${id}`;
88
+ const profileUrl = `https://www.picuki.com/${type === 'tagged' ? 'profile-tagged' : 'profile'}/${id}`;
74
89
 
75
- const data = await cache.tryGet(
76
- `picuki-${id}-profile-${includeStories}`,
77
- async () => {
78
- const _r = await puppeteerGet(profileUrl, browser, includeStories);
79
- return _r;
80
- },
81
- config.cache.routeExpire,
82
- false
83
- );
90
+ const key = `picuki-${id}-${type}-${includeStories}`;
91
+ const data = await cache.tryGet(key, () => puppeteerGet(profileUrl, browser, includeStories), config.cache.routeExpire, false);
84
92
  const $ = load(data);
85
93
 
86
94
  const profileName = $('.profile-name-bottom').text();
95
+ const profileTitle = type === 'tagged' ? `${profileName} (@${id}) tagged posts - Picuki` : `${profileName} (@${id}) public posts - Picuki`;
87
96
  const profileImg = $('.profile-avatar > img').attr('src');
88
97
  const profileDescription = $('.profile-description').text();
89
98
 
90
- const list = $('ul.box-photos [data-s="media"]').get();
99
+ const list = $('ul.box-photos [data-s="media"]').toArray();
100
+
101
+ let items: DataItem[] = [];
91
102
 
92
- let items = [];
103
+ let description: string;
93
104
 
94
105
  if (includeStories) {
95
106
  const stories_wrapper = $('.stories_wrapper');
96
107
  if (stories_wrapper.length) {
97
108
  const storyItems = $(stories_wrapper)
98
109
  .find('.item')
99
- .get()
110
+ .toArray()
100
111
  .map((item) => {
101
112
  const $item = $(item);
102
- let title = $item.find('.stories_count');
103
- title = title.length ? title.text() : '';
104
- const pubDate = title ? chrono.parseDate(title) : new Date();
113
+ const titleElement = $item.find('.stories_count');
114
+ const title = titleElement.length ? titleElement.text() : '';
115
+ const pubDate = chrono.parseDate(title) || new Date();
105
116
  const postBox = $item.find('.launchLightbox');
106
117
  const poster = postBox.attr('data-video-poster');
107
118
  const href = postBox.attr('href');
108
119
  const type = postBox.attr('data-post-type'); // video / image
109
120
  const origin = postBox.attr('data-origin');
110
121
  const storiesBackground = $item.find('.stories_background');
111
- const storiesBackgroundUrl = storiesBackground && storiesBackground.css('background-image').match(/url\('?(.*)'?\)/);
112
- const storiesBackgroundUrlSrc = storiesBackgroundUrl && storiesBackgroundUrl[1];
113
- let description;
122
+ const storiesBackgroundUrl = storiesBackground?.css('background-image')?.match(/url\('?(.*)'?\)/);
123
+ const storiesBackgroundUrlSrc = storiesBackgroundUrl?.[1];
114
124
  if (type === 'video') {
115
125
  description = art(path.join(__dirname, 'templates/video.art'), {
116
126
  videoSrcs: [href, origin].filter(Boolean),
117
- videoPoster: poster || storiesBackgroundUrlSrc || '',
127
+ videoPoster: poster ?? storiesBackgroundUrlSrc ?? '',
118
128
  });
119
129
  } else if (type === 'image') {
120
- description = `<img src="${href || poster || storiesBackgroundUrlSrc || ''}" alt="Instagram Story">`;
130
+ description = `<img src="${href ?? poster ?? storiesBackgroundUrlSrc ?? ''}" alt="Instagram Story">`;
121
131
  }
122
132
 
123
133
  return {
124
- title: 'Instagram Story' + (pubDate ? '' : `: ${title}`),
134
+ title: title ? `Instagram Story: ${title}` : 'Instagram Story',
125
135
  author: `@${id}`,
126
136
  description,
127
137
  link: href,
@@ -149,8 +159,8 @@ async function handler(ctx) {
149
159
  $('.single-photo img').each((_, item) => {
150
160
  html += $(item).toString();
151
161
  });
152
- $('.single-photo video').each((_, item) => {
153
- item = $(item);
162
+ $('.single-photo video').each((_, element) => {
163
+ const item = $(element);
154
164
  let videoSrc = item.attr('src');
155
165
  if (videoSrc === undefined) {
156
166
  videoSrc = item.children().attr('src');
@@ -158,8 +168,9 @@ async function handler(ctx) {
158
168
  const videoPoster = item.attr('poster');
159
169
  let origin = item.parent().attr('onclick');
160
170
  if (origin) {
161
- origin = origin.match(/window\.open\('([^']*)'/);
162
- origin = origin && origin[1];
171
+ const regex = /window\.open\('([^']*)'/;
172
+ const match = regex.exec(origin);
173
+ origin = match?.[1];
163
174
  }
164
175
  html += art(path.join(__dirname, 'templates/video.art'), {
165
176
  videoSrcs: [videoSrc, origin].filter(Boolean),
@@ -172,15 +183,15 @@ async function handler(ctx) {
172
183
  items = [
173
184
  ...items,
174
185
  ...(await Promise.all(
175
- list.map(async (post) => {
176
- post = $(post);
186
+ list.map(async (item) => {
187
+ const post = $(item);
177
188
 
178
189
  const postLink = post.find('.photo > a').attr('href');
179
190
  const postTime = post.find('.time');
180
- const pubDate = postTime ? chrono.parseDate(postTime.text()) : new Date();
191
+ const pubDate = postTime?.text() ? (chrono.parseDate(postTime.text()) ?? new Date()) : new Date();
181
192
  const media_displayVideo = await getMedia(postLink);
182
193
  const postText = post
183
- .find('.photo-description')
194
+ .find('.photo-action-description')
184
195
  .text()
185
196
  .trim()
186
197
  .replaceAll(/[^\S\n]+/g, ' ')
@@ -206,7 +217,7 @@ async function handler(ctx) {
206
217
  await browser.close();
207
218
 
208
219
  return {
209
- title: `${profileName} (@${id}) - Picuki`,
220
+ title: profileTitle,
210
221
  link: profileUrl,
211
222
  image: profileImg,
212
223
  description: profileDescription,