podverse-parser 5.0.0-beta.2 → 5.0.1

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 (55) hide show
  1. package/package.json +6 -3
  2. package/.nvmrc +0 -1
  3. package/eslint.config.mjs +0 -38
  4. package/src/index.ts +0 -3
  5. package/src/lib/chapters/chapters.ts +0 -54
  6. package/src/lib/compat/channel.ts +0 -287
  7. package/src/lib/compat/chapters/chapters.ts +0 -23
  8. package/src/lib/compat/partytime/channel.ts +0 -289
  9. package/src/lib/compat/partytime/compatFull.ts +0 -7
  10. package/src/lib/compat/partytime/funding.ts +0 -8
  11. package/src/lib/compat/partytime/item.ts +0 -273
  12. package/src/lib/compat/partytime/liveItem.ts +0 -18
  13. package/src/lib/compat/partytime/value.ts +0 -64
  14. package/src/lib/rss/base/handleParsedManyData.ts +0 -16
  15. package/src/lib/rss/base/handleParsedOneData.ts +0 -17
  16. package/src/lib/rss/channel/channel.ts +0 -55
  17. package/src/lib/rss/channel/channelAbout.ts +0 -13
  18. package/src/lib/rss/channel/channelChat.ts +0 -14
  19. package/src/lib/rss/channel/channelDescription.ts +0 -14
  20. package/src/lib/rss/channel/channelFunding.ts +0 -14
  21. package/src/lib/rss/channel/channelImage.ts +0 -14
  22. package/src/lib/rss/channel/channelLicense.ts +0 -14
  23. package/src/lib/rss/channel/channelLocation.ts +0 -14
  24. package/src/lib/rss/channel/channelPerson.ts +0 -14
  25. package/src/lib/rss/channel/channelPodroll.ts +0 -21
  26. package/src/lib/rss/channel/channelRemoteItem.ts +0 -14
  27. package/src/lib/rss/channel/channelSeason.ts +0 -14
  28. package/src/lib/rss/channel/channelSocialInteract.ts +0 -14
  29. package/src/lib/rss/channel/channelTrailer.ts +0 -31
  30. package/src/lib/rss/channel/channelTxt.ts +0 -14
  31. package/src/lib/rss/channel/channelValue.ts +0 -30
  32. package/src/lib/rss/feed/feed.ts +0 -79
  33. package/src/lib/rss/hash/parsedFeed.ts +0 -9
  34. package/src/lib/rss/item/item.ts +0 -85
  35. package/src/lib/rss/item/itemAbout.ts +0 -13
  36. package/src/lib/rss/item/itemChaptersFeed.ts +0 -14
  37. package/src/lib/rss/item/itemChat.ts +0 -14
  38. package/src/lib/rss/item/itemContentLink.ts +0 -0
  39. package/src/lib/rss/item/itemDescription.ts +0 -14
  40. package/src/lib/rss/item/itemEnclosure.ts +0 -35
  41. package/src/lib/rss/item/itemImage.ts +0 -14
  42. package/src/lib/rss/item/itemLicense.ts +0 -14
  43. package/src/lib/rss/item/itemLocation.ts +0 -14
  44. package/src/lib/rss/item/itemPerson.ts +0 -14
  45. package/src/lib/rss/item/itemSeason.ts +0 -26
  46. package/src/lib/rss/item/itemSeasonEpisode.ts +0 -14
  47. package/src/lib/rss/item/itemSocialInteract.ts +0 -14
  48. package/src/lib/rss/item/itemSoundbite.ts +0 -14
  49. package/src/lib/rss/item/itemTranscript.ts +0 -14
  50. package/src/lib/rss/item/itemTxt.ts +0 -14
  51. package/src/lib/rss/item/itemValue.ts +0 -60
  52. package/src/lib/rss/liveItem/liveItem.ts +0 -34
  53. package/src/lib/rss/parser.ts +0 -85
  54. package/src/module-alias-config.ts +0 -8
  55. package/tsconfig.json +0 -25
@@ -1,14 +0,0 @@
1
- import { Episode } from "podcast-partytime";
2
- import { EntityManager, Item, ItemLocationService } from "podverse-orm";
3
- import { compatItemLocationDto } from "@parser/lib/compat/partytime/item";
4
- import { handleParsedOneData } from "../base/handleParsedOneData";
5
-
6
- export const handleParsedItemLocation = async (
7
- parsedItem: Episode,
8
- item: Item,
9
- transactionalEntityManager: EntityManager
10
- ) => {
11
- const itemLocationService = new ItemLocationService(transactionalEntityManager);
12
- const itemLocationDto = compatItemLocationDto(parsedItem);
13
- await handleParsedOneData(item, itemLocationService, itemLocationDto);
14
- };
@@ -1,14 +0,0 @@
1
- import { Episode } from "podcast-partytime";
2
- import { EntityManager, Item, ItemPersonService } from "podverse-orm";
3
- import { compatItemPersonDtos } from "@parser/lib/compat/partytime/item";
4
- import { handleParsedManyData } from "../base/handleParsedManyData";
5
-
6
- export const handleParsedItemPerson = async (
7
- parsedItem: Episode,
8
- item: Item,
9
- transactionalEntityManager: EntityManager
10
- ) => {
11
- const itemPersonService = new ItemPersonService(transactionalEntityManager);
12
- const itemPersonDtos = compatItemPersonDtos(parsedItem);
13
- await handleParsedManyData(item, itemPersonService, itemPersonDtos);
14
- };
@@ -1,26 +0,0 @@
1
- import { Episode } from "podcast-partytime";
2
- import { ChannelSeasonIndex, EntityManager, Item, ItemSeasonDto,
3
- ItemSeasonService } from "podverse-orm";
4
- import { compatItemSeasonDto } from "@parser/lib/compat/partytime/item";
5
- import { handleParsedOneData } from "../base/handleParsedOneData";
6
-
7
- export const handleParsedItemSeason = async (
8
- parsedItem: Episode,
9
- item: Item,
10
- channelSeasonIndex: ChannelSeasonIndex,
11
- transactionalEntityManager: EntityManager
12
- ) => {
13
- const itemSeasonService = new ItemSeasonService(transactionalEntityManager);
14
- const itemSeasonDto = compatItemSeasonDto(parsedItem);
15
-
16
- if (itemSeasonDto) {
17
- const channel_season = itemSeasonDto.number ? channelSeasonIndex[itemSeasonDto.number] : null;
18
- if (channel_season) {
19
- const enrichedItemSeasonDto: ItemSeasonDto = {
20
- title: itemSeasonDto.title,
21
- channel_season
22
- };
23
- await handleParsedOneData(item, itemSeasonService, enrichedItemSeasonDto);
24
- }
25
- }
26
- };
@@ -1,14 +0,0 @@
1
- import { Episode } from "podcast-partytime";
2
- import { EntityManager, Item, ItemSeasonEpisodeService } from "podverse-orm";
3
- import { compatItemSeasonEpisodeDto } from "@parser/lib/compat/partytime/item";
4
- import { handleParsedOneData } from "../base/handleParsedOneData";
5
-
6
- export const handleParsedItemSeasonEpisode = async (
7
- parsedItem: Episode,
8
- item: Item,
9
- transactionalEntityManager: EntityManager
10
- ) => {
11
- const itemSeasonEpisodeService = new ItemSeasonEpisodeService(transactionalEntityManager);
12
- const itemSeasonEpisodeDto = compatItemSeasonEpisodeDto(parsedItem);
13
- await handleParsedOneData(item, itemSeasonEpisodeService, itemSeasonEpisodeDto);
14
- };
@@ -1,14 +0,0 @@
1
- import { Episode } from "podcast-partytime";
2
- import { EntityManager, Item, ItemSocialInteractService } from "podverse-orm";
3
- import { compatItemSocialInteractDtos } from "@parser/lib/compat/partytime/item";
4
- import { handleParsedManyData } from "../base/handleParsedManyData";
5
-
6
- export const handleParsedItemSocialInteract = async (
7
- parsedItem: Episode,
8
- item: Item,
9
- transactionalEntityManager: EntityManager
10
- ) => {
11
- const itemSocialInteractService = new ItemSocialInteractService(transactionalEntityManager);
12
- const itemSocialInteractDtos = compatItemSocialInteractDtos(parsedItem);
13
- await handleParsedManyData(item, itemSocialInteractService, itemSocialInteractDtos);
14
- };
@@ -1,14 +0,0 @@
1
- import { Episode } from "podcast-partytime";
2
- import { EntityManager, Item, ItemSoundbiteService } from "podverse-orm";
3
- import { compatItemSoundbiteDtos } from "@parser/lib/compat/partytime/item";
4
- import { handleParsedManyData } from "../base/handleParsedManyData";
5
-
6
- export const handleParsedItemSoundbite = async (
7
- parsedItem: Episode,
8
- item: Item,
9
- transactionalEntityManager: EntityManager
10
- ) => {
11
- const itemSoundbiteService = new ItemSoundbiteService(transactionalEntityManager);
12
- const itemSoundbiteDtos = compatItemSoundbiteDtos(parsedItem);
13
- await handleParsedManyData(item, itemSoundbiteService, itemSoundbiteDtos);
14
- };
@@ -1,14 +0,0 @@
1
- import { Episode } from "podcast-partytime";
2
- import { EntityManager, Item, ItemTranscriptService } from "podverse-orm";
3
- import { compatItemTranscriptDtos } from "@parser/lib/compat/partytime/item";
4
- import { handleParsedManyData } from "../base/handleParsedManyData";
5
-
6
- export const handleParsedItemTranscript = async (
7
- parsedItem: Episode,
8
- item: Item,
9
- transactionalEntityManager: EntityManager
10
- ) => {
11
- const itemTranscriptService = new ItemTranscriptService(transactionalEntityManager);
12
- const itemTranscriptDtos = compatItemTranscriptDtos(parsedItem);
13
- await handleParsedManyData(item, itemTranscriptService, itemTranscriptDtos);
14
- };
@@ -1,14 +0,0 @@
1
- import { Episode } from "podcast-partytime";
2
- import { EntityManager, Item, ItemTxtService } from "podverse-orm";
3
- import { compatItemTxtDtos } from "@parser/lib/compat/partytime/item";
4
- import { handleParsedManyData } from "../base/handleParsedManyData";
5
-
6
- export const handleParsedItemTxt = async (
7
- parsedItem: Episode,
8
- item: Item,
9
- transactionalEntityManager: EntityManager
10
- ) => {
11
- const itemTxtService = new ItemTxtService(transactionalEntityManager);
12
- const itemTxtDtos = compatItemTxtDtos(parsedItem);
13
- await handleParsedManyData(item, itemTxtService, itemTxtDtos);
14
- };
@@ -1,60 +0,0 @@
1
- import { Episode } from "podcast-partytime";
2
- import { EntityManager, Item, ItemValueService, ItemValueRecipientService, ItemValueTimeSplitService,
3
- ItemValueTimeSplitRecipientService, ItemValueTimeSplitRemoteItemService
4
- } from "podverse-orm";
5
- import { compatItemValueDtos } from "@parser/lib/compat/partytime/item";
6
-
7
- export const handleParsedItemValue = async (
8
- parsedItem: Episode,
9
- item: Item,
10
- transactionalEntityManager: EntityManager
11
- ) => {
12
- const itemValueService = new ItemValueService(transactionalEntityManager);
13
- const itemValueDtos = compatItemValueDtos(parsedItem);
14
- const itemValueRecipientService = new ItemValueRecipientService(transactionalEntityManager);
15
- const itemValueTimeSplitService = new ItemValueTimeSplitService(transactionalEntityManager);
16
- const itemValueTimeSplitRecipientService = new ItemValueTimeSplitRecipientService(transactionalEntityManager);
17
- const itemValueTimeSplitRemoteItemService = new ItemValueTimeSplitRemoteItemService(transactionalEntityManager);
18
-
19
- if (itemValueDtos.length > 0) {
20
- for (const itemValueDto of itemValueDtos) {
21
- const item_value = await itemValueService.update(item, itemValueDto.item_value);
22
-
23
- const itemValueRecipientDtos = itemValueDto.item_value_recipients;
24
- if (itemValueRecipientDtos.length > 0) {
25
- for (const itemValueRecipientDto of itemValueRecipientDtos) {
26
- await itemValueRecipientService.update(item_value, itemValueRecipientDto);
27
- }
28
- } else {
29
- await itemValueRecipientService.deleteAll(item_value);
30
- }
31
-
32
- const itemValueTimeSplitDtos = itemValueDto.item_value_time_splits;
33
- if (itemValueTimeSplitDtos.length > 0) {
34
- for (const itemValueTimeSplitDto of itemValueTimeSplitDtos) {
35
- const item_value_time_split = await itemValueTimeSplitService.update(item_value, itemValueTimeSplitDto.meta);
36
-
37
- const itemValueTimeSplitRecipientDtos = itemValueTimeSplitDto.item_value_time_splits_recipients;
38
- if (itemValueTimeSplitRecipientDtos.length > 0) {
39
- for (const itemValueTimeSplitRecipientDto of itemValueTimeSplitRecipientDtos) {
40
- await itemValueTimeSplitRecipientService.update(item_value_time_split, itemValueTimeSplitRecipientDto);
41
- }
42
- } else {
43
- await itemValueTimeSplitRecipientService.deleteAll(item_value_time_split);
44
- }
45
-
46
- const itemValueTimeSplitRemoteItemDto = itemValueTimeSplitDto.item_value_time_splits_remote_item;
47
- if (itemValueTimeSplitRemoteItemDto) {
48
- await itemValueTimeSplitRemoteItemService.update(item_value_time_split, itemValueTimeSplitRemoteItemDto);
49
- } else {
50
- await itemValueTimeSplitRemoteItemService.deleteAll(item_value_time_split);
51
- }
52
- }
53
- } else {
54
- await itemValueTimeSplitService.deleteAll(item_value);
55
- }
56
- }
57
- } else {
58
- await itemValueService.deleteAll(item);
59
- }
60
- };
@@ -1,34 +0,0 @@
1
- import { chunkArray } from "podverse-helpers";
2
- import { Phase4PodcastLiveItem } from "podcast-partytime/dist/parser/phase/phase-4";
3
- import { AppDataSource, Channel, ChannelSeasonIndex, ItemService, LiveItemService } from "podverse-orm";
4
- import { compatLiveItemsDtos } from "@parser/lib/compat/partytime/liveItem";
5
- import { handleParsedItem } from "../item/item";
6
-
7
- export const handleParsedLiveItems = async (parsedLiveItems: Phase4PodcastLiveItem[], channel: Channel, channelSeasonIndex: ChannelSeasonIndex) => {
8
- const itemService = new ItemService();
9
- const existingLiveItems = await itemService.getAllItemsWithLiveItemByChannel(channel, { select: ['id'] });
10
- const existingLiveItemIds = existingLiveItems.map(live_item => live_item.id);
11
- const updatedLiveItemIds: number[] = [];
12
- const liveItemObjDtos = compatLiveItemsDtos(parsedLiveItems);
13
-
14
- const liveItemObjDtosBatchs = chunkArray(liveItemObjDtos, 100);
15
- for (const liveItemObjDtosBatch of liveItemObjDtosBatchs) {
16
- await AppDataSource.manager.transaction(async transactionalEntityManager => {
17
- for (const liveItemObjDto of liveItemObjDtosBatch) {
18
- // PTDO: how to make any unnecessary?
19
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- const itemDto = liveItemObjDto.item as any;
21
-
22
- const item = await handleParsedItem(itemDto, channel, channelSeasonIndex, transactionalEntityManager);
23
- updatedLiveItemIds.push(item.id);
24
-
25
- const liveItemService = new LiveItemService();
26
- const liveItemDto = liveItemObjDto.liveItem;
27
- await liveItemService.update(item, liveItemDto);
28
- }
29
- });
30
- }
31
-
32
- const itemIdsToDelete = existingLiveItemIds.filter(id => !updatedLiveItemIds.includes(id));
33
- await itemService.deleteMany(itemIdsToDelete);
34
- };
@@ -1,85 +0,0 @@
1
- import { parseFeed } from 'podcast-partytime';
2
- import { request } from 'podverse-helpers';
3
- import { ChannelService, ChannelSeasonService, FeedLogService, FeedService } from 'podverse-orm';
4
- import { handleParsedChannel } from "@parser/lib/rss/channel/channel";
5
- import { handleParsedItems } from './item/item';
6
- import { handleParsedChannelSeasons } from './channel/channelSeason';
7
- import { handleParsedLiveItems } from './liveItem/liveItem';
8
- import { handleGetRSSFeed, handleParsedFeed } from './feed/feed';
9
-
10
- /*
11
- NOTE: All RSS feeds that have a podcast_index_id will be saved to the database.
12
- RSS feeds without podcast_index_id (Add By RSS feeds) will NOT be saved to the database.
13
- */
14
-
15
- // TEMP: exists for development purposes
16
- export const parseAllRSSFeeds = async () => {
17
- const feedService = new FeedService();
18
- const feeds = await feedService.getAll();
19
- for (const feed of feeds) {
20
- return await parseRSSFeedAndSaveToDatabase(feed.url, feed?.channel?.podcast_index_id);
21
- }
22
- };
23
-
24
- export const getAndParseRSSFeed = async (url: string) => {
25
- const xml: string = await request(url);
26
- const parsedFeed = parseFeed(xml, { allowMissingGuid: true });
27
-
28
- if (!parsedFeed) {
29
- throw new Error(`getAndParseRSSFeed: parsedFeed not found for ${url}`);
30
- }
31
-
32
- return parsedFeed;
33
- };
34
-
35
- // export const parseRSSAddByRSSFeed = async (url: string) => {
36
- // const parsedFeed = await getAndParseRSSFeed(url);
37
- // const compatData = convertParsedRSSFeedToCompat(parsedFeed);
38
- // return compatData;
39
- // };
40
-
41
- export const parseRSSFeedAndSaveToDatabase = async (url: string, podcast_index_id: number) => {
42
- const feedService = new FeedService();
43
-
44
- let feed = await feedService.getBy({ url, podcast_index_id });
45
- if (!feed) {
46
- throw new Error(`parseRSSFeedAndSaveToDatabase: feed not found for ${url}`);
47
- }
48
-
49
- const parsedFeed = await handleGetRSSFeed(feed);
50
- feed = await handleParsedFeed(parsedFeed, url, podcast_index_id);
51
-
52
- try {
53
- await feedService.update(feed.id, { is_parsing: new Date() });
54
-
55
- const channelService = new ChannelService();
56
- const channel = await channelService.getOrCreateByPodcastIndexId({ feed, podcast_index_id });
57
-
58
- // ChannelSeason must be parsed before anything else, because the channel season rows
59
- // need to be created for other data to have a foreign key to them.
60
- await handleParsedChannelSeasons(parsedFeed, channel);
61
- const channelSeasonService = new ChannelSeasonService();
62
- const channelSeasonIndex = await channelSeasonService.getChannelSeasonIndex(channel);
63
-
64
- await handleParsedChannel(parsedFeed, channel, channelSeasonIndex);
65
-
66
- // PTDO: if publisher feed, handle publisher remote item data
67
- // else handle parsed items
68
- await handleParsedItems(parsedFeed.items, channel, channelSeasonIndex);
69
-
70
- if (parsedFeed.podcastLiveItems) {
71
- await handleParsedLiveItems(parsedFeed.podcastLiveItems, channel, channelSeasonIndex);
72
- }
73
-
74
- // TODO: handle new item notifications
75
-
76
- // TODO: handle new live_item notifications
77
-
78
- const feedLogService = new FeedLogService();
79
- await feedLogService.update(feed, { last_finished_parse_time: new Date() });
80
- } finally {
81
- await feedService.update(feed.id, { is_parsing: null });
82
- }
83
-
84
- return feed;
85
- };
@@ -1,8 +0,0 @@
1
- const moduleAlias = require('module-alias');
2
- const path = require('path');
3
-
4
- moduleAlias.addAliases({
5
- '@parser': path.join(__dirname, '')
6
- });
7
-
8
- export {};
package/tsconfig.json DELETED
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES6",
4
- "module": "commonjs",
5
- "strict": true,
6
- "noImplicitAny": true,
7
- "esModuleInterop": true,
8
- "experimentalDecorators": true,
9
- "emitDecoratorMetadata": true,
10
- "skipLibCheck": true,
11
- "declaration": true,
12
- "declarationMap": true,
13
- "forceConsistentCasingInFileNames": true,
14
- "outDir": "./dist",
15
- "rootDir": "./src",
16
- "baseUrl": "./",
17
- "paths": {
18
- "@parser/*": ["src/*"]
19
- }
20
- },
21
- "include": [
22
- "./src/**/*.ts"
23
- ],
24
- "exclude": ["node_modules"]
25
- }