feedscout 1.7.0 → 1.8.0

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 (91) hide show
  1. package/dist/common/discover/utils.cjs +11 -8
  2. package/dist/common/discover/utils.js +11 -8
  3. package/dist/common/locales.cjs +11 -4
  4. package/dist/common/locales.js +11 -4
  5. package/dist/common/types.d.cts +5 -4
  6. package/dist/common/types.d.ts +5 -4
  7. package/dist/common/uris/guess/utils.cjs +1 -1
  8. package/dist/common/uris/guess/utils.js +1 -1
  9. package/dist/common/uris/headers/index.cjs +1 -1
  10. package/dist/common/uris/headers/index.js +1 -1
  11. package/dist/common/uris/platform/types.d.cts +2 -2
  12. package/dist/common/uris/platform/types.d.ts +2 -2
  13. package/dist/common/utils.cjs +5 -1
  14. package/dist/common/utils.js +5 -1
  15. package/dist/favicons/defaults.cjs +6 -1
  16. package/dist/favicons/defaults.js +6 -1
  17. package/dist/favicons/platform/handlers/bluesky.cjs +1 -1
  18. package/dist/favicons/platform/handlers/bluesky.js +1 -1
  19. package/dist/favicons/platform/handlers/codeberg.cjs +4 -3
  20. package/dist/favicons/platform/handlers/codeberg.js +4 -3
  21. package/dist/favicons/platform/handlers/devto.cjs +31 -0
  22. package/dist/favicons/platform/handlers/devto.js +31 -0
  23. package/dist/favicons/platform/handlers/github.cjs +4 -3
  24. package/dist/favicons/platform/handlers/github.js +4 -3
  25. package/dist/favicons/platform/handlers/githubGist.cjs +4 -3
  26. package/dist/favicons/platform/handlers/githubGist.js +4 -3
  27. package/dist/favicons/platform/handlers/gitlab.cjs +38 -0
  28. package/dist/favicons/platform/handlers/gitlab.js +38 -0
  29. package/dist/favicons/platform/handlers/lobsters.cjs +3 -3
  30. package/dist/favicons/platform/handlers/lobsters.js +3 -3
  31. package/dist/favicons/platform/handlers/mastodon.cjs +5 -3
  32. package/dist/favicons/platform/handlers/mastodon.js +5 -3
  33. package/dist/favicons/platform/handlers/reddit.cjs +10 -8
  34. package/dist/favicons/platform/handlers/reddit.js +10 -8
  35. package/dist/feeds/defaults.cjs +4 -2
  36. package/dist/feeds/defaults.js +4 -2
  37. package/dist/feeds/platform/handlers/applePodcasts.cjs +26 -0
  38. package/dist/feeds/platform/handlers/applePodcasts.js +26 -0
  39. package/dist/feeds/platform/handlers/behance.cjs +2 -2
  40. package/dist/feeds/platform/handlers/behance.js +2 -2
  41. package/dist/feeds/platform/handlers/dailymotion.cjs +4 -4
  42. package/dist/feeds/platform/handlers/dailymotion.js +4 -4
  43. package/dist/feeds/platform/handlers/devto.cjs +6 -4
  44. package/dist/feeds/platform/handlers/devto.js +5 -5
  45. package/dist/feeds/platform/handlers/gitlab.cjs +4 -0
  46. package/dist/feeds/platform/handlers/gitlab.js +1 -1
  47. package/dist/feeds/platform/handlers/hatenablog.cjs +4 -4
  48. package/dist/feeds/platform/handlers/hatenablog.js +4 -4
  49. package/dist/feeds/platform/handlers/itchio.cjs +10 -10
  50. package/dist/feeds/platform/handlers/itchio.js +10 -10
  51. package/dist/feeds/platform/handlers/lobsters.cjs +8 -8
  52. package/dist/feeds/platform/handlers/lobsters.js +8 -8
  53. package/dist/feeds/platform/handlers/mastodon.cjs +4 -4
  54. package/dist/feeds/platform/handlers/mastodon.js +4 -4
  55. package/dist/feeds/platform/handlers/medium.cjs +10 -10
  56. package/dist/feeds/platform/handlers/medium.js +10 -10
  57. package/dist/feeds/platform/handlers/paragraph.cjs +2 -2
  58. package/dist/feeds/platform/handlers/paragraph.js +2 -2
  59. package/dist/feeds/platform/handlers/producthunt.cjs +4 -4
  60. package/dist/feeds/platform/handlers/producthunt.js +4 -4
  61. package/dist/feeds/platform/handlers/reddit.cjs +10 -10
  62. package/dist/feeds/platform/handlers/reddit.js +10 -10
  63. package/dist/feeds/platform/handlers/stackExchange.cjs +6 -6
  64. package/dist/feeds/platform/handlers/stackExchange.js +6 -6
  65. package/dist/feeds/platform/handlers/steam.cjs +4 -4
  66. package/dist/feeds/platform/handlers/steam.js +4 -4
  67. package/dist/feeds/platform/handlers/substack.cjs +10 -3
  68. package/dist/feeds/platform/handlers/substack.js +11 -4
  69. package/dist/feeds/platform/handlers/tumblr.cjs +2 -2
  70. package/dist/feeds/platform/handlers/tumblr.js +2 -2
  71. package/dist/feeds/platform/handlers/v2ex.cjs +4 -4
  72. package/dist/feeds/platform/handlers/v2ex.js +4 -4
  73. package/dist/feeds/platform/handlers/vimeo.cjs +2 -2
  74. package/dist/feeds/platform/handlers/vimeo.js +2 -2
  75. package/dist/feeds/platform/handlers/wordpress.cjs +6 -6
  76. package/dist/feeds/platform/handlers/wordpress.js +6 -6
  77. package/dist/feeds/platform/handlers/ximalaya.cjs +2 -2
  78. package/dist/feeds/platform/handlers/ximalaya.js +2 -2
  79. package/dist/feeds/platform/handlers/youtube.cjs +36 -21
  80. package/dist/feeds/platform/handlers/youtube.js +36 -21
  81. package/dist/hubs/discover/index.cjs +1 -2
  82. package/dist/hubs/discover/index.js +1 -2
  83. package/dist/hubs/feed/index.cjs +4 -4
  84. package/dist/hubs/feed/index.js +4 -4
  85. package/dist/hubs/headers/index.cjs +2 -2
  86. package/dist/hubs/headers/index.js +2 -2
  87. package/dist/hubs/html/index.cjs +2 -2
  88. package/dist/hubs/html/index.js +2 -2
  89. package/package.json +4 -3
  90. package/dist/hubs/discover/utils.cjs +0 -18
  91. package/dist/hubs/discover/utils.js +0 -18
@@ -1,13 +1,20 @@
1
- import { composeHint, isSubdomainOf } from "../../../common/utils.js";
1
+ import { composeHint, isHostOf, isSubdomainOf } from "../../../common/utils.js";
2
2
  //#region src/feeds/platform/handlers/substack.ts
3
+ const profileRegex = /^\/@([\w-]+)/;
3
4
  const substackHandler = {
4
5
  match: (url) => {
5
- return isSubdomainOf(url, "substack.com");
6
+ if (isSubdomainOf(url, "substack.com")) return true;
7
+ return isHostOf(url, "substack.com") && profileRegex.test(new URL(url).pathname);
6
8
  },
7
9
  resolve: (url) => {
8
- const { origin } = new URL(url);
10
+ const parsed = new URL(url);
11
+ const profileMatch = parsed.pathname.match(profileRegex);
12
+ if (isHostOf(url, "substack.com") && profileMatch?.[1]) return [{
13
+ uri: `https://${profileMatch[1]}.substack.com/feed`,
14
+ hint: composeHint("substack:newsletter")
15
+ }];
9
16
  return [{
10
- uri: `${origin}/feed`,
17
+ uri: `${parsed.origin}/feed`,
11
18
  hint: composeHint("substack:newsletter")
12
19
  }];
13
20
  }
@@ -1,14 +1,14 @@
1
1
  const require_utils = require("../../../common/utils.cjs");
2
2
  //#region src/feeds/platform/handlers/tumblr.ts
3
3
  const domains = ["tumblr.com"];
4
- const tagPathRegex = /^\/tagged\/([^/]+)/;
4
+ const tagRegex = /^\/tagged\/([^/]+)/;
5
5
  const tumblrHandler = {
6
6
  match: (url) => {
7
7
  return require_utils.isSubdomainOf(url, domains);
8
8
  },
9
9
  resolve: (url) => {
10
10
  const { origin, pathname } = new URL(url);
11
- const tagMatch = pathname.match(tagPathRegex);
11
+ const tagMatch = pathname.match(tagRegex);
12
12
  if (tagMatch?.[1]) return [{
13
13
  uri: `${origin}/tagged/${tagMatch[1]}/rss`,
14
14
  hint: require_utils.composeHint("tumblr:tag")
@@ -1,14 +1,14 @@
1
1
  import { composeHint, isSubdomainOf } from "../../../common/utils.js";
2
2
  //#region src/feeds/platform/handlers/tumblr.ts
3
3
  const domains = ["tumblr.com"];
4
- const tagPathRegex = /^\/tagged\/([^/]+)/;
4
+ const tagRegex = /^\/tagged\/([^/]+)/;
5
5
  const tumblrHandler = {
6
6
  match: (url) => {
7
7
  return isSubdomainOf(url, domains);
8
8
  },
9
9
  resolve: (url) => {
10
10
  const { origin, pathname } = new URL(url);
11
- const tagMatch = pathname.match(tagPathRegex);
11
+ const tagMatch = pathname.match(tagRegex);
12
12
  if (tagMatch?.[1]) return [{
13
13
  uri: `${origin}/tagged/${tagMatch[1]}/rss`,
14
14
  hint: composeHint("tumblr:tag")
@@ -1,7 +1,7 @@
1
1
  const require_utils = require("../../../common/utils.cjs");
2
2
  //#region src/feeds/platform/handlers/v2ex.ts
3
- const nodePathRegex = /^\/go\/([^/]+)/;
4
- const memberPathRegex = /^\/member\/([^/]+)/;
3
+ const nodeRegex = /^\/go\/([^/]+)/;
4
+ const memberRegex = /^\/member\/([^/]+)/;
5
5
  const hosts = ["www.v2ex.com", "v2ex.com"];
6
6
  const v2exHandler = {
7
7
  match: (url) => {
@@ -9,12 +9,12 @@ const v2exHandler = {
9
9
  },
10
10
  resolve: (url) => {
11
11
  const { pathname, searchParams } = new URL(url);
12
- const nodeMatch = pathname.match(nodePathRegex);
12
+ const nodeMatch = pathname.match(nodeRegex);
13
13
  if (nodeMatch?.[1]) return [{
14
14
  uri: `https://www.v2ex.com/feed/${nodeMatch[1]}.xml`,
15
15
  hint: require_utils.composeHint("v2ex:node")
16
16
  }];
17
- const memberMatch = pathname.match(memberPathRegex);
17
+ const memberMatch = pathname.match(memberRegex);
18
18
  if (memberMatch?.[1]) return [{
19
19
  uri: `https://www.v2ex.com/feed/member/${memberMatch[1]}.xml`,
20
20
  hint: require_utils.composeHint("v2ex:member")
@@ -1,7 +1,7 @@
1
1
  import { composeHint, isHostOf } from "../../../common/utils.js";
2
2
  //#region src/feeds/platform/handlers/v2ex.ts
3
- const nodePathRegex = /^\/go\/([^/]+)/;
4
- const memberPathRegex = /^\/member\/([^/]+)/;
3
+ const nodeRegex = /^\/go\/([^/]+)/;
4
+ const memberRegex = /^\/member\/([^/]+)/;
5
5
  const hosts = ["www.v2ex.com", "v2ex.com"];
6
6
  const v2exHandler = {
7
7
  match: (url) => {
@@ -9,12 +9,12 @@ const v2exHandler = {
9
9
  },
10
10
  resolve: (url) => {
11
11
  const { pathname, searchParams } = new URL(url);
12
- const nodeMatch = pathname.match(nodePathRegex);
12
+ const nodeMatch = pathname.match(nodeRegex);
13
13
  if (nodeMatch?.[1]) return [{
14
14
  uri: `https://www.v2ex.com/feed/${nodeMatch[1]}.xml`,
15
15
  hint: composeHint("v2ex:node")
16
16
  }];
17
- const memberMatch = pathname.match(memberPathRegex);
17
+ const memberMatch = pathname.match(memberRegex);
18
18
  if (memberMatch?.[1]) return [{
19
19
  uri: `https://www.v2ex.com/feed/member/${memberMatch[1]}.xml`,
20
20
  hint: composeHint("v2ex:member")
@@ -1,6 +1,6 @@
1
1
  const require_utils = require("../../../common/utils.cjs");
2
2
  //#region src/feeds/platform/handlers/vimeo.ts
3
- const numericPathRegex = /^\d+$/;
3
+ const numericRegex = /^\d+$/;
4
4
  const hosts = ["vimeo.com", "www.vimeo.com"];
5
5
  const excludedPaths = [
6
6
  "about",
@@ -50,7 +50,7 @@ const vimeoHandler = {
50
50
  }];
51
51
  if (pathSegments.length > 0) {
52
52
  const user = pathSegments[0];
53
- if (!require_utils.isAnyOf(user, excludedPaths) && !numericPathRegex.test(user)) {
53
+ if (!require_utils.isAnyOf(user, excludedPaths) && !numericRegex.test(user)) {
54
54
  const feeds = [{
55
55
  uri: `${origin}/${user}/videos/rss`,
56
56
  hint: require_utils.composeHint("vimeo:videos")
@@ -1,6 +1,6 @@
1
1
  import { composeHint, isAnyOf, isHostOf } from "../../../common/utils.js";
2
2
  //#region src/feeds/platform/handlers/vimeo.ts
3
- const numericPathRegex = /^\d+$/;
3
+ const numericRegex = /^\d+$/;
4
4
  const hosts = ["vimeo.com", "www.vimeo.com"];
5
5
  const excludedPaths = [
6
6
  "about",
@@ -50,7 +50,7 @@ const vimeoHandler = {
50
50
  }];
51
51
  if (pathSegments.length > 0) {
52
52
  const user = pathSegments[0];
53
- if (!isAnyOf(user, excludedPaths) && !numericPathRegex.test(user)) {
53
+ if (!isAnyOf(user, excludedPaths) && !numericRegex.test(user)) {
54
54
  const feeds = [{
55
55
  uri: `${origin}/${user}/videos/rss`,
56
56
  hint: composeHint("vimeo:videos")
@@ -1,8 +1,8 @@
1
1
  const require_utils = require("../../../common/utils.cjs");
2
2
  //#region src/feeds/platform/handlers/wordpress.ts
3
- const categoryPathRegex = /^\/category\/([^/]+)/;
4
- const tagPathRegex = /^\/tag\/([^/]+)/;
5
- const authorPathRegex = /^\/author\/([^/]+)/;
3
+ const categoryRegex = /^\/category\/([^/]+)/;
4
+ const tagRegex = /^\/tag\/([^/]+)/;
5
+ const authorRegex = /^\/author\/([^/]+)/;
6
6
  const wordpressHandler = {
7
7
  match: (url) => {
8
8
  return require_utils.isSubdomainOf(url, "wordpress.com");
@@ -10,17 +10,17 @@ const wordpressHandler = {
10
10
  resolve: (url) => {
11
11
  const { origin, pathname } = new URL(url);
12
12
  const uris = [];
13
- const categoryMatch = pathname.match(categoryPathRegex);
13
+ const categoryMatch = pathname.match(categoryRegex);
14
14
  if (categoryMatch?.[1]) uris.push({
15
15
  uri: [`${origin}/category/${categoryMatch[1]}/feed/`, `${origin}/category/${categoryMatch[1]}/?feed=rss`],
16
16
  hint: require_utils.composeHint("wordpress:category")
17
17
  });
18
- const tagMatch = pathname.match(tagPathRegex);
18
+ const tagMatch = pathname.match(tagRegex);
19
19
  if (tagMatch?.[1]) uris.push({
20
20
  uri: [`${origin}/tag/${tagMatch[1]}/feed/`, `${origin}/tag/${tagMatch[1]}/?feed=rss`],
21
21
  hint: require_utils.composeHint("wordpress:tag")
22
22
  });
23
- const authorMatch = pathname.match(authorPathRegex);
23
+ const authorMatch = pathname.match(authorRegex);
24
24
  if (authorMatch?.[1]) uris.push({
25
25
  uri: [`${origin}/author/${authorMatch[1]}/feed/`, `${origin}/author/${authorMatch[1]}/?feed=rss`],
26
26
  hint: require_utils.composeHint("wordpress:author")
@@ -1,8 +1,8 @@
1
1
  import { composeHint, isSubdomainOf } from "../../../common/utils.js";
2
2
  //#region src/feeds/platform/handlers/wordpress.ts
3
- const categoryPathRegex = /^\/category\/([^/]+)/;
4
- const tagPathRegex = /^\/tag\/([^/]+)/;
5
- const authorPathRegex = /^\/author\/([^/]+)/;
3
+ const categoryRegex = /^\/category\/([^/]+)/;
4
+ const tagRegex = /^\/tag\/([^/]+)/;
5
+ const authorRegex = /^\/author\/([^/]+)/;
6
6
  const wordpressHandler = {
7
7
  match: (url) => {
8
8
  return isSubdomainOf(url, "wordpress.com");
@@ -10,17 +10,17 @@ const wordpressHandler = {
10
10
  resolve: (url) => {
11
11
  const { origin, pathname } = new URL(url);
12
12
  const uris = [];
13
- const categoryMatch = pathname.match(categoryPathRegex);
13
+ const categoryMatch = pathname.match(categoryRegex);
14
14
  if (categoryMatch?.[1]) uris.push({
15
15
  uri: [`${origin}/category/${categoryMatch[1]}/feed/`, `${origin}/category/${categoryMatch[1]}/?feed=rss`],
16
16
  hint: composeHint("wordpress:category")
17
17
  });
18
- const tagMatch = pathname.match(tagPathRegex);
18
+ const tagMatch = pathname.match(tagRegex);
19
19
  if (tagMatch?.[1]) uris.push({
20
20
  uri: [`${origin}/tag/${tagMatch[1]}/feed/`, `${origin}/tag/${tagMatch[1]}/?feed=rss`],
21
21
  hint: composeHint("wordpress:tag")
22
22
  });
23
- const authorMatch = pathname.match(authorPathRegex);
23
+ const authorMatch = pathname.match(authorRegex);
24
24
  if (authorMatch?.[1]) uris.push({
25
25
  uri: [`${origin}/author/${authorMatch[1]}/feed/`, `${origin}/author/${authorMatch[1]}/?feed=rss`],
26
26
  hint: composeHint("wordpress:author")
@@ -1,6 +1,6 @@
1
1
  const require_utils = require("../../../common/utils.cjs");
2
2
  //#region src/feeds/platform/handlers/ximalaya.ts
3
- const albumPathRegex = /^\/album\/(\d+)/;
3
+ const albumRegex = /^\/album\/(\d+)/;
4
4
  const hosts = ["www.ximalaya.com", "ximalaya.com"];
5
5
  const ximalayaHandler = {
6
6
  match: (url) => {
@@ -8,7 +8,7 @@ const ximalayaHandler = {
8
8
  },
9
9
  resolve: (url) => {
10
10
  const { pathname } = new URL(url);
11
- const id = pathname.match(albumPathRegex)?.[1];
11
+ const id = pathname.match(albumRegex)?.[1];
12
12
  if (!id) return [];
13
13
  return [{
14
14
  uri: `https://www.ximalaya.com/album/${id}.xml`,
@@ -1,6 +1,6 @@
1
1
  import { composeHint, isHostOf } from "../../../common/utils.js";
2
2
  //#region src/feeds/platform/handlers/ximalaya.ts
3
- const albumPathRegex = /^\/album\/(\d+)/;
3
+ const albumRegex = /^\/album\/(\d+)/;
4
4
  const hosts = ["www.ximalaya.com", "ximalaya.com"];
5
5
  const ximalayaHandler = {
6
6
  match: (url) => {
@@ -8,7 +8,7 @@ const ximalayaHandler = {
8
8
  },
9
9
  resolve: (url) => {
10
10
  const { pathname } = new URL(url);
11
- const id = pathname.match(albumPathRegex)?.[1];
11
+ const id = pathname.match(albumRegex)?.[1];
12
12
  if (!id) return [];
13
13
  return [{
14
14
  uri: `https://www.ximalaya.com/album/${id}.xml`,
@@ -1,10 +1,10 @@
1
1
  const require_utils = require("../../../common/utils.cjs");
2
2
  //#region src/feeds/platform/handlers/youtube.ts
3
3
  const channelIdRegex = /"(?:channelId|externalId)":"(UC[a-zA-Z0-9_-]+)"/;
4
- const channelPathRegex = /^\/channel\/(UC[a-zA-Z0-9_-]+)/;
5
- const handlePathRegex = /^\/@([^/]+)/;
6
- const userPathRegex = /^\/user\/([^/]+)/;
7
- const customPathRegex = /^\/c\/([^/]+)/;
4
+ const channelRegex = /^\/channel\/(UC[a-zA-Z0-9_-]+)/;
5
+ const handleRegex = /^\/@([^/]+)/;
6
+ const userRegex = /^\/user\/([^/]+)/;
7
+ const customRegex = /^\/c\/([^/]+)/;
8
8
  const channelPrefixRegex = /^UC/;
9
9
  const hosts = [
10
10
  "youtube.com",
@@ -16,38 +16,53 @@ const hosts = [
16
16
  const extractChannelIdFromContent = (content) => {
17
17
  return content.match(channelIdRegex)?.[1];
18
18
  };
19
- const getAllUploadsPlaylistId = (channelId) => {
20
- return channelId.replace(channelPrefixRegex, "UU");
21
- };
22
- const getVideosOnlyPlaylistId = (channelId) => {
23
- return channelId.replace(channelPrefixRegex, "UULF");
24
- };
25
- const getShortsOnlyPlaylistId = (channelId) => {
26
- return channelId.replace(channelPrefixRegex, "UUSH");
27
- };
28
- const getLiveStreamsOnlyPlaylistId = (channelId) => {
29
- return channelId.replace(channelPrefixRegex, "UULV");
19
+ const playlistPrefix = (prefix, channelId) => {
20
+ return channelId.replace(channelPrefixRegex, prefix);
30
21
  };
31
22
  const feedUrl = (param, value) => {
32
23
  return `https://www.youtube.com/feeds/videos.xml?${param}=${value}`;
33
24
  };
34
25
  const pushChannelUris = (uris, channelId) => {
35
26
  uris.push({
36
- uri: [feedUrl("channel_id", channelId), feedUrl("playlist_id", getAllUploadsPlaylistId(channelId))],
27
+ uri: [feedUrl("channel_id", channelId), feedUrl("playlist_id", playlistPrefix("UU", channelId))],
37
28
  hint: require_utils.composeHint("youtube:all")
38
29
  });
39
30
  uris.push({
40
- uri: feedUrl("playlist_id", getVideosOnlyPlaylistId(channelId)),
31
+ uri: feedUrl("playlist_id", playlistPrefix("UULF", channelId)),
41
32
  hint: require_utils.composeHint("youtube:videos")
42
33
  });
43
34
  uris.push({
44
- uri: feedUrl("playlist_id", getShortsOnlyPlaylistId(channelId)),
35
+ uri: feedUrl("playlist_id", playlistPrefix("UUSH", channelId)),
45
36
  hint: require_utils.composeHint("youtube:shorts")
46
37
  });
47
38
  uris.push({
48
- uri: feedUrl("playlist_id", getLiveStreamsOnlyPlaylistId(channelId)),
39
+ uri: feedUrl("playlist_id", playlistPrefix("UULV", channelId)),
49
40
  hint: require_utils.composeHint("youtube:live")
50
41
  });
42
+ uris.push({
43
+ uri: feedUrl("playlist_id", playlistPrefix("UULP", channelId)),
44
+ hint: require_utils.composeHint("youtube:popular-videos")
45
+ });
46
+ uris.push({
47
+ uri: feedUrl("playlist_id", playlistPrefix("UUPS", channelId)),
48
+ hint: require_utils.composeHint("youtube:popular-shorts")
49
+ });
50
+ uris.push({
51
+ uri: feedUrl("playlist_id", playlistPrefix("UUPV", channelId)),
52
+ hint: require_utils.composeHint("youtube:popular-live")
53
+ });
54
+ uris.push({
55
+ uri: feedUrl("playlist_id", playlistPrefix("UUMO", channelId)),
56
+ hint: require_utils.composeHint("youtube:member-videos")
57
+ });
58
+ uris.push({
59
+ uri: feedUrl("playlist_id", playlistPrefix("UUMS", channelId)),
60
+ hint: require_utils.composeHint("youtube:member-shorts")
61
+ });
62
+ uris.push({
63
+ uri: feedUrl("playlist_id", playlistPrefix("UUMV", channelId)),
64
+ hint: require_utils.composeHint("youtube:member-live")
65
+ });
51
66
  };
52
67
  const youtubeHandler = {
53
68
  match: (url) => {
@@ -56,7 +71,7 @@ const youtubeHandler = {
56
71
  resolve: (url, content) => {
57
72
  const parsedUrl = new URL(url);
58
73
  const uris = [];
59
- const channelMatch = parsedUrl.pathname.match(channelPathRegex);
74
+ const channelMatch = parsedUrl.pathname.match(channelRegex);
60
75
  if (channelMatch?.[1]) {
61
76
  const channelId = channelMatch[1];
62
77
  pushChannelUris(uris, channelId);
@@ -67,7 +82,7 @@ const youtubeHandler = {
67
82
  hint: require_utils.composeHint("youtube:playlist")
68
83
  });
69
84
  if (uris.length === 0 && content) {
70
- if (parsedUrl.searchParams.has("v") || parsedUrl.hostname.includes("youtu.be") && parsedUrl.pathname.length > 1 || parsedUrl.pathname.match(handlePathRegex) || parsedUrl.pathname.match(userPathRegex) || parsedUrl.pathname.match(customPathRegex)) {
85
+ if (parsedUrl.searchParams.has("v") || parsedUrl.hostname.includes("youtu.be") && parsedUrl.pathname.length > 1 || parsedUrl.pathname.match(handleRegex) || parsedUrl.pathname.match(userRegex) || parsedUrl.pathname.match(customRegex)) {
71
86
  const channelId = extractChannelIdFromContent(content);
72
87
  if (channelId) pushChannelUris(uris, channelId);
73
88
  }
@@ -1,10 +1,10 @@
1
1
  import { composeHint, isHostOf } from "../../../common/utils.js";
2
2
  //#region src/feeds/platform/handlers/youtube.ts
3
3
  const channelIdRegex = /"(?:channelId|externalId)":"(UC[a-zA-Z0-9_-]+)"/;
4
- const channelPathRegex = /^\/channel\/(UC[a-zA-Z0-9_-]+)/;
5
- const handlePathRegex = /^\/@([^/]+)/;
6
- const userPathRegex = /^\/user\/([^/]+)/;
7
- const customPathRegex = /^\/c\/([^/]+)/;
4
+ const channelRegex = /^\/channel\/(UC[a-zA-Z0-9_-]+)/;
5
+ const handleRegex = /^\/@([^/]+)/;
6
+ const userRegex = /^\/user\/([^/]+)/;
7
+ const customRegex = /^\/c\/([^/]+)/;
8
8
  const channelPrefixRegex = /^UC/;
9
9
  const hosts = [
10
10
  "youtube.com",
@@ -16,38 +16,53 @@ const hosts = [
16
16
  const extractChannelIdFromContent = (content) => {
17
17
  return content.match(channelIdRegex)?.[1];
18
18
  };
19
- const getAllUploadsPlaylistId = (channelId) => {
20
- return channelId.replace(channelPrefixRegex, "UU");
21
- };
22
- const getVideosOnlyPlaylistId = (channelId) => {
23
- return channelId.replace(channelPrefixRegex, "UULF");
24
- };
25
- const getShortsOnlyPlaylistId = (channelId) => {
26
- return channelId.replace(channelPrefixRegex, "UUSH");
27
- };
28
- const getLiveStreamsOnlyPlaylistId = (channelId) => {
29
- return channelId.replace(channelPrefixRegex, "UULV");
19
+ const playlistPrefix = (prefix, channelId) => {
20
+ return channelId.replace(channelPrefixRegex, prefix);
30
21
  };
31
22
  const feedUrl = (param, value) => {
32
23
  return `https://www.youtube.com/feeds/videos.xml?${param}=${value}`;
33
24
  };
34
25
  const pushChannelUris = (uris, channelId) => {
35
26
  uris.push({
36
- uri: [feedUrl("channel_id", channelId), feedUrl("playlist_id", getAllUploadsPlaylistId(channelId))],
27
+ uri: [feedUrl("channel_id", channelId), feedUrl("playlist_id", playlistPrefix("UU", channelId))],
37
28
  hint: composeHint("youtube:all")
38
29
  });
39
30
  uris.push({
40
- uri: feedUrl("playlist_id", getVideosOnlyPlaylistId(channelId)),
31
+ uri: feedUrl("playlist_id", playlistPrefix("UULF", channelId)),
41
32
  hint: composeHint("youtube:videos")
42
33
  });
43
34
  uris.push({
44
- uri: feedUrl("playlist_id", getShortsOnlyPlaylistId(channelId)),
35
+ uri: feedUrl("playlist_id", playlistPrefix("UUSH", channelId)),
45
36
  hint: composeHint("youtube:shorts")
46
37
  });
47
38
  uris.push({
48
- uri: feedUrl("playlist_id", getLiveStreamsOnlyPlaylistId(channelId)),
39
+ uri: feedUrl("playlist_id", playlistPrefix("UULV", channelId)),
49
40
  hint: composeHint("youtube:live")
50
41
  });
42
+ uris.push({
43
+ uri: feedUrl("playlist_id", playlistPrefix("UULP", channelId)),
44
+ hint: composeHint("youtube:popular-videos")
45
+ });
46
+ uris.push({
47
+ uri: feedUrl("playlist_id", playlistPrefix("UUPS", channelId)),
48
+ hint: composeHint("youtube:popular-shorts")
49
+ });
50
+ uris.push({
51
+ uri: feedUrl("playlist_id", playlistPrefix("UUPV", channelId)),
52
+ hint: composeHint("youtube:popular-live")
53
+ });
54
+ uris.push({
55
+ uri: feedUrl("playlist_id", playlistPrefix("UUMO", channelId)),
56
+ hint: composeHint("youtube:member-videos")
57
+ });
58
+ uris.push({
59
+ uri: feedUrl("playlist_id", playlistPrefix("UUMS", channelId)),
60
+ hint: composeHint("youtube:member-shorts")
61
+ });
62
+ uris.push({
63
+ uri: feedUrl("playlist_id", playlistPrefix("UUMV", channelId)),
64
+ hint: composeHint("youtube:member-live")
65
+ });
51
66
  };
52
67
  const youtubeHandler = {
53
68
  match: (url) => {
@@ -56,7 +71,7 @@ const youtubeHandler = {
56
71
  resolve: (url, content) => {
57
72
  const parsedUrl = new URL(url);
58
73
  const uris = [];
59
- const channelMatch = parsedUrl.pathname.match(channelPathRegex);
74
+ const channelMatch = parsedUrl.pathname.match(channelRegex);
60
75
  if (channelMatch?.[1]) {
61
76
  const channelId = channelMatch[1];
62
77
  pushChannelUris(uris, channelId);
@@ -67,7 +82,7 @@ const youtubeHandler = {
67
82
  hint: composeHint("youtube:playlist")
68
83
  });
69
84
  if (uris.length === 0 && content) {
70
- if (parsedUrl.searchParams.has("v") || parsedUrl.hostname.includes("youtu.be") && parsedUrl.pathname.length > 1 || parsedUrl.pathname.match(handlePathRegex) || parsedUrl.pathname.match(userPathRegex) || parsedUrl.pathname.match(customPathRegex)) {
85
+ if (parsedUrl.searchParams.has("v") || parsedUrl.hostname.includes("youtu.be") && parsedUrl.pathname.length > 1 || parsedUrl.pathname.match(handleRegex) || parsedUrl.pathname.match(userRegex) || parsedUrl.pathname.match(customRegex)) {
71
86
  const channelId = extractChannelIdFromContent(content);
72
87
  if (channelId) pushChannelUris(uris, channelId);
73
88
  }
@@ -3,7 +3,6 @@ const require_utils$1 = require("../../common/discover/utils.cjs");
3
3
  const require_index = require("../feed/index.cjs");
4
4
  const require_index$1 = require("../headers/index.cjs");
5
5
  const require_index$2 = require("../html/index.cjs");
6
- const require_utils$2 = require("./utils.cjs");
7
6
  //#region src/hubs/discover/index.ts
8
7
  const discoverHubs = async (input, options = {}) => {
9
8
  const { methods = [
@@ -11,7 +10,7 @@ const discoverHubs = async (input, options = {}) => {
11
10
  "feed",
12
11
  "html"
13
12
  ], fetchFn = require_utils$1.defaultFetchFn, resolveUrlFn = require_utils.resolveUrl } = options;
14
- const normalizedInput = await require_utils$2.normalizeInput(input, fetchFn);
13
+ const normalizedInput = await require_utils$1.normalizeInput(input, fetchFn);
15
14
  const results = [];
16
15
  if (methods.includes("headers") && normalizedInput.headers) {
17
16
  const headerHubs = require_index$1.discoverHubsFromHeaders(normalizedInput.headers, normalizedInput.url, resolveUrlFn);
@@ -1,9 +1,8 @@
1
1
  import { resolveUrl } from "../../common/utils.js";
2
- import { defaultFetchFn } from "../../common/discover/utils.js";
2
+ import { defaultFetchFn, normalizeInput } from "../../common/discover/utils.js";
3
3
  import { discoverHubsFromFeed } from "../feed/index.js";
4
4
  import { discoverHubsFromHeaders } from "../headers/index.js";
5
5
  import { discoverHubsFromHtml } from "../html/index.js";
6
- import { normalizeInput } from "./utils.js";
7
6
  //#region src/hubs/discover/index.ts
8
7
  const discoverHubs = async (input, options = {}) => {
9
8
  const { methods = [
@@ -9,9 +9,9 @@ const discoverHubsFromFeed = (content, baseUrl, resolveUrlFn = require_utils.res
9
9
  const { format, feed } = (0, feedsmith.parseFeed)(content);
10
10
  if (format === "json") {
11
11
  const hubs = feed.hubs ?? [];
12
- const topic = feed.feed_url ? resolveUrlFn(feed.feed_url, baseUrl) : baseUrl;
12
+ const topic = feed.feed_url ? resolveUrlFn(feed.feed_url, baseUrl) ?? feed.feed_url : baseUrl;
13
13
  return hubs.filter((hub) => hub.url).map((hub) => ({
14
- hub: resolveUrlFn(hub.url, baseUrl),
14
+ hub: resolveUrlFn(hub.url, baseUrl) ?? hub.url,
15
15
  topic
16
16
  }));
17
17
  }
@@ -19,9 +19,9 @@ const discoverHubsFromFeed = (content, baseUrl, resolveUrlFn = require_utils.res
19
19
  const hubUris = getLinksWithRel(links, "hub");
20
20
  if (hubUris.length > 0) {
21
21
  const selfUris = getLinksWithRel(links, "self");
22
- const topic = selfUris[0] ? resolveUrlFn(selfUris[0], baseUrl) : baseUrl;
22
+ const topic = selfUris[0] ? resolveUrlFn(selfUris[0], baseUrl) ?? selfUris[0] : baseUrl;
23
23
  return hubUris.map((hub) => ({
24
- hub: resolveUrlFn(hub, baseUrl),
24
+ hub: resolveUrlFn(hub, baseUrl) ?? hub,
25
25
  topic
26
26
  }));
27
27
  }
@@ -9,9 +9,9 @@ const discoverHubsFromFeed = (content, baseUrl, resolveUrlFn = resolveUrl) => {
9
9
  const { format, feed } = parseFeed(content);
10
10
  if (format === "json") {
11
11
  const hubs = feed.hubs ?? [];
12
- const topic = feed.feed_url ? resolveUrlFn(feed.feed_url, baseUrl) : baseUrl;
12
+ const topic = feed.feed_url ? resolveUrlFn(feed.feed_url, baseUrl) ?? feed.feed_url : baseUrl;
13
13
  return hubs.filter((hub) => hub.url).map((hub) => ({
14
- hub: resolveUrlFn(hub.url, baseUrl),
14
+ hub: resolveUrlFn(hub.url, baseUrl) ?? hub.url,
15
15
  topic
16
16
  }));
17
17
  }
@@ -19,9 +19,9 @@ const discoverHubsFromFeed = (content, baseUrl, resolveUrlFn = resolveUrl) => {
19
19
  const hubUris = getLinksWithRel(links, "hub");
20
20
  if (hubUris.length > 0) {
21
21
  const selfUris = getLinksWithRel(links, "self");
22
- const topic = selfUris[0] ? resolveUrlFn(selfUris[0], baseUrl) : baseUrl;
22
+ const topic = selfUris[0] ? resolveUrlFn(selfUris[0], baseUrl) ?? selfUris[0] : baseUrl;
23
23
  return hubUris.map((hub) => ({
24
- hub: resolveUrlFn(hub, baseUrl),
24
+ hub: resolveUrlFn(hub, baseUrl) ?? hub,
25
25
  topic
26
26
  }));
27
27
  }
@@ -7,9 +7,9 @@ const discoverHubsFromHeaders = (headers, baseUrl, resolveUrlFn = require_utils.
7
7
  const hubUris = require_index.discoverUrisFromHeaders(headers, { linkSelectors: hubSelector });
8
8
  if (hubUris.length === 0) return [];
9
9
  const selfUris = require_index.discoverUrisFromHeaders(headers, { linkSelectors: selfSelector });
10
- const topic = selfUris[0] ? resolveUrlFn(selfUris[0], baseUrl) : baseUrl;
10
+ const topic = selfUris[0] ? resolveUrlFn(selfUris[0], baseUrl) ?? selfUris[0] : baseUrl;
11
11
  return hubUris.map((hub) => ({
12
- hub: resolveUrlFn(hub, baseUrl),
12
+ hub: resolveUrlFn(hub, baseUrl) ?? hub,
13
13
  topic
14
14
  }));
15
15
  };
@@ -7,9 +7,9 @@ const discoverHubsFromHeaders = (headers, baseUrl, resolveUrlFn = resolveUrl) =>
7
7
  const hubUris = discoverUrisFromHeaders(headers, { linkSelectors: hubSelector });
8
8
  if (hubUris.length === 0) return [];
9
9
  const selfUris = discoverUrisFromHeaders(headers, { linkSelectors: selfSelector });
10
- const topic = selfUris[0] ? resolveUrlFn(selfUris[0], baseUrl) : baseUrl;
10
+ const topic = selfUris[0] ? resolveUrlFn(selfUris[0], baseUrl) ?? selfUris[0] : baseUrl;
11
11
  return hubUris.map((hub) => ({
12
- hub: resolveUrlFn(hub, baseUrl),
12
+ hub: resolveUrlFn(hub, baseUrl) ?? hub,
13
13
  topic
14
14
  }));
15
15
  };
@@ -18,9 +18,9 @@ const discoverHubsFromHtml = (content, baseUrl, resolveUrlFn = require_utils.res
18
18
  ...htmlOptions,
19
19
  linkSelectors: selfSelector
20
20
  });
21
- const topic = selfUris[0] ? resolveUrlFn(selfUris[0], baseUrl) : baseUrl;
21
+ const topic = selfUris[0] ? resolveUrlFn(selfUris[0], baseUrl) ?? selfUris[0] : baseUrl;
22
22
  return hubUris.map((hub) => ({
23
- hub: resolveUrlFn(hub, baseUrl),
23
+ hub: resolveUrlFn(hub, baseUrl) ?? hub,
24
24
  topic
25
25
  }));
26
26
  };
@@ -18,9 +18,9 @@ const discoverHubsFromHtml = (content, baseUrl, resolveUrlFn = resolveUrl) => {
18
18
  ...htmlOptions,
19
19
  linkSelectors: selfSelector
20
20
  });
21
- const topic = selfUris[0] ? resolveUrlFn(selfUris[0], baseUrl) : baseUrl;
21
+ const topic = selfUris[0] ? resolveUrlFn(selfUris[0], baseUrl) ?? selfUris[0] : baseUrl;
22
22
  return hubUris.map((hub) => ({
23
- hub: resolveUrlFn(hub, baseUrl),
23
+ hub: resolveUrlFn(hub, baseUrl) ?? hub,
24
24
  topic
25
25
  }));
26
26
  };
package/package.json CHANGED
@@ -108,13 +108,14 @@
108
108
  },
109
109
  "dependencies": {
110
110
  "feedsmith": "^2.9.1",
111
- "htmlparser2": "^10.1.0"
111
+ "htmlparser2": "^10.1.0",
112
+ "typescript": "^6.0.2"
112
113
  },
113
114
  "devDependencies": {
114
115
  "@types/bun": "^1.3.11",
115
- "kvalita": "1.12.2",
116
+ "kvalita": "1.12.4",
116
117
  "tsdown": "^0.21.7",
117
118
  "vitepress": "^2.0.0-alpha.17"
118
119
  },
119
- "version": "1.7.0"
120
+ "version": "1.8.0"
120
121
  }
@@ -1,18 +0,0 @@
1
- //#region src/hubs/discover/utils.ts
2
- const normalizeInput = async (input, fetchFn) => {
3
- if (typeof input === "string") {
4
- const response = await fetchFn(input);
5
- return {
6
- url: response.url,
7
- content: typeof response.body === "string" ? response.body : void 0,
8
- headers: response.headers
9
- };
10
- }
11
- return {
12
- url: input.url,
13
- content: input.content,
14
- headers: input.headers
15
- };
16
- };
17
- //#endregion
18
- exports.normalizeInput = normalizeInput;
@@ -1,18 +0,0 @@
1
- //#region src/hubs/discover/utils.ts
2
- const normalizeInput = async (input, fetchFn) => {
3
- if (typeof input === "string") {
4
- const response = await fetchFn(input);
5
- return {
6
- url: response.url,
7
- content: typeof response.body === "string" ? response.body : void 0,
8
- headers: response.headers
9
- };
10
- }
11
- return {
12
- url: input.url,
13
- content: input.content,
14
- headers: input.headers
15
- };
16
- };
17
- //#endregion
18
- export { normalizeInput };