podverse-parser 5.0.0-beta.2 → 5.0.0-beta.3

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 +4 -1
  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,31 +0,0 @@
1
- import { FeedObject } from "podcast-partytime";
2
- import { Channel, ChannelSeason, ChannelTrailerDto, ChannelTrailerService, EntityManager } from "podverse-orm";
3
- import { compatChannelTrailerDtos } from "@parser/lib/compat/partytime/channel";
4
-
5
- export const handleParsedChannelTrailer = async (
6
- parsedFeed: FeedObject,
7
- channel: Channel,
8
- channelSeasonIndex: Record<number, ChannelSeason>,
9
- transactionalEntityManager: EntityManager
10
- ) => {
11
- const channelTrailerService = new ChannelTrailerService(transactionalEntityManager);
12
- const channelTrailerDtos = compatChannelTrailerDtos(parsedFeed);
13
-
14
- const enrichedChannelTrailerDtos: ChannelTrailerDto[] = channelTrailerDtos.map((channelTrailerDto) => {
15
- const channel_season = channelTrailerDto.season ? channelSeasonIndex[channelTrailerDto.season] : null;
16
- return {
17
- url: channelTrailerDto.url,
18
- pubdate: channelTrailerDto.pubdate,
19
- title: channelTrailerDto.title,
20
- length: channelTrailerDto.length,
21
- type: channelTrailerDto.type,
22
- channel_season
23
- };
24
- });
25
-
26
- if (channelTrailerDtos.length > 0) {
27
- await channelTrailerService.updateMany(channel, enrichedChannelTrailerDtos);
28
- } else {
29
- await channelTrailerService.deleteAll(channel);
30
- }
31
- };
@@ -1,14 +0,0 @@
1
- import { FeedObject } from "podcast-partytime";
2
- import { Channel, ChannelTxtService, EntityManager } from "podverse-orm";
3
- import { compatChannelTxtDtos } from "@parser/lib/compat/partytime/channel";
4
- import { handleParsedManyData } from "../base/handleParsedManyData";
5
-
6
- export const handleParsedChannelTxt = async (
7
- parsedFeed: FeedObject,
8
- channel: Channel,
9
- transactionalEntityManager: EntityManager
10
- ) => {
11
- const channelTxtService = new ChannelTxtService(transactionalEntityManager);
12
- const channelTxtDtos = compatChannelTxtDtos(parsedFeed);
13
- await handleParsedManyData(channel, channelTxtService, channelTxtDtos);
14
- };
@@ -1,30 +0,0 @@
1
- import { FeedObject } from "podcast-partytime";
2
- import { Channel, ChannelValueService, ChannelValueRecipientService, EntityManager } from "podverse-orm";
3
- import { compatChannelValueDtos } from "@parser/lib/compat/partytime/channel";
4
-
5
- export const handleParsedChannelValue = async (
6
- parsedFeed: FeedObject,
7
- channel: Channel,
8
- transactionalEntityManager: EntityManager
9
- ) => {
10
- const channelValueService = new ChannelValueService(transactionalEntityManager);
11
- const channelValueDtos = compatChannelValueDtos(parsedFeed);
12
- const channelValueRecipientService = new ChannelValueRecipientService(transactionalEntityManager);
13
-
14
- if (channelValueDtos.length > 0) {
15
- for (const channelValueDto of channelValueDtos) {
16
- const channel_value = await channelValueService.update(channel, channelValueDto.channel_value);
17
-
18
- const channelValueRecipientDtos = channelValueDto.channel_value_recipients;
19
- if (channelValueRecipientDtos.length > 0) {
20
- for (const channelValueRecipientDto of channelValueRecipientDtos) {
21
- await channelValueRecipientService.update(channel_value, channelValueRecipientDto);
22
- }
23
- } else {
24
- await channelValueService.deleteAll(channel);
25
- }
26
- }
27
- } else {
28
- await channelValueService.deleteAll(channel);
29
- }
30
- };
@@ -1,79 +0,0 @@
1
- import { FeedObject } from "podcast-partytime";
2
- import { throwRequestError } from "podverse-helpers";
3
- import { checkIfFeedFlagStatusShouldParse, Feed, FeedService, FeedLogService } from "podverse-orm";
4
- import { getParsedFeedMd5Hash } from "../hash/parsedFeed";
5
- import { getAndParseRSSFeed } from "../parser";
6
-
7
- export const handleGetRSSFeed = async (feed: Feed): Promise<FeedObject> => {
8
- const feedLogService = new FeedLogService();
9
- let parsedFeed: FeedObject | null = null;
10
-
11
- try {
12
- parsedFeed = await getAndParseRSSFeed(feed.url);
13
- await feedLogService.update(feed, {
14
- last_http_status: 200,
15
- last_good_http_status_time: new Date()
16
- });
17
- } catch (error) {
18
- // TODO: how to handle errors?
19
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- const statusCode = (error as any).statusCode as number;
21
- const feedLog = await feedLogService.get(feed);
22
- if (statusCode) {
23
- await feedLogService.update(feed, {
24
- last_http_status: statusCode,
25
- parse_errors: (feedLog?.parse_errors || 0) + 1,
26
- });
27
- }
28
- return throwRequestError(error);
29
- }
30
-
31
- if (!parsedFeed) {
32
- const feedLog = await feedLogService.get(feed);
33
- await feedLogService.update(feed, {
34
- last_http_status: 200,
35
- last_finished_parse_time: new Date(),
36
- parse_errors: (feedLog?.parse_errors || 0) + 1,
37
- });
38
- return throwRequestError('parsedFeed no data found');
39
- }
40
-
41
- return parsedFeed;
42
- };
43
-
44
- export const handleParsedFeed = async (parsedFeed: FeedObject, url: string, podcast_index_id: number): Promise<Feed> => {
45
- const feedService = new FeedService();
46
- const feed = await feedService.getOrCreate({ url, podcast_index_id });
47
-
48
- // TODO: move before partytime parsing
49
- if (!checkIfFeedFlagStatusShouldParse(feed.feed_flag_status.id)) {
50
- throw new Error(`parseRSSFeedAndSaveToDatabase: feed_flag_status.status is not None or AlwaysAllow for ${url}`);
51
- }
52
-
53
- checkIfFeedIsParsing(feed);
54
-
55
- const currentFeedFileHash = getParsedFeedMd5Hash(parsedFeed);
56
-
57
- if (feed.last_parsed_file_hash === currentFeedFileHash) {
58
- throw new Error(`Feed ${feed.id} has no changes since last parsed.`);
59
- }
60
-
61
- return feedService.update(feed.id, { last_parsed_file_hash: currentFeedFileHash });
62
- };
63
-
64
- const checkIfFeedIsParsing = (feed: Feed): void => {
65
- // TODO: handle with caching db / redis instead of database?
66
- if (feed.is_parsing) {
67
- const parsingDate = new Date(feed.is_parsing);
68
- const currentDate = new Date();
69
- const timeDifference = (currentDate.getTime() - parsingDate.getTime()) / (1000 * 60);
70
-
71
- if (isNaN(parsingDate.getTime())) {
72
- throw new Error(`Feed ${feed.id} has an invalid parsing date`);
73
- }
74
-
75
- if (timeDifference <= 30) {
76
- throw new Error(`Feed ${feed.id} is already parsing`);
77
- }
78
- }
79
- };
@@ -1,9 +0,0 @@
1
- import { getMd5Hash } from "podverse-helpers";
2
- import { FeedObject } from "podcast-partytime";
3
-
4
- export const getParsedFeedMd5Hash = (parsedFeed: FeedObject): string => {
5
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
6
- const { lastUpdate, lastBuildDate, pubDate, ...parsedFeedPruned } = parsedFeed;
7
- const currentFeedFileHash = getMd5Hash(parsedFeedPruned);
8
- return currentFeedFileHash;
9
- };
@@ -1,85 +0,0 @@
1
- import { Episode } from "podcast-partytime";
2
- import { chunkArray } from "podverse-helpers";
3
- import { AppDataSource, Channel, ChannelSeasonIndex, EntityManager, ItemService } from "podverse-orm";
4
- import { compatItemDto } from "@parser/lib/compat/partytime/item";
5
- import { handleParsedItemAbout } from "@parser/lib/rss/item/itemAbout";
6
- import { handleParsedItemChaptersFeed } from "@parser/lib/rss/item/itemChaptersFeed";
7
- import { handleParsedItemDescription } from "@parser/lib/rss/item/itemDescription";
8
- import { handleParsedItemEnclosure } from "@parser/lib/rss/item/itemEnclosure";
9
- import { handleParsedItemImage } from "@parser/lib/rss/item/itemImage";
10
- import { handleParsedItemLicense } from "@parser/lib/rss/item/itemLicense";
11
- import { handleParsedItemLocation } from "@parser/lib/rss/item/itemLocation";
12
- import { handleParsedItemPerson } from "@parser/lib/rss/item/itemPerson";
13
- import { handleParsedItemSeason } from "@parser/lib/rss/item/itemSeason";
14
- import { handleParsedItemSeasonEpisode } from "@parser/lib/rss/item/itemSeasonEpisode";
15
- import { handleParsedItemSocialInteract } from "@parser/lib/rss/item/itemSocialInteract";
16
- import { handleParsedItemSoundbite } from "@parser/lib/rss/item/itemSoundbite";
17
- import { handleParsedItemTranscript } from "@parser/lib/rss/item/itemTranscript";
18
- import { handleParsedItemTxt } from "@parser/lib/rss/item/itemTxt";
19
- import { handleParsedItemValue } from "@parser/lib/rss/item/itemValue";
20
- import { handleParsedItemChat } from "@parser/lib/rss/item/itemChat";
21
-
22
- export const handleParsedItems = async (parsedItems: Episode[], channel: Channel, channelSeasonIndex: ChannelSeasonIndex) => {
23
- const itemService = new ItemService();
24
- const existingItems = await itemService.getAllItemsByChannel(channel, { select: ['id'] });
25
- const existingItemIds = existingItems.map(item => item.id);
26
- const updatedItemIds: number[] = [];
27
-
28
- const parsedItemBatchs = chunkArray(parsedItems, 100);
29
- for (const parsedItemBatch of parsedItemBatchs) {
30
- await AppDataSource.manager.transaction(async transactionalEntityManager => {
31
- for (const parsedItem of parsedItemBatch) {
32
- const item = await handleParsedItem(
33
- parsedItem,
34
- channel,
35
- channelSeasonIndex,
36
- transactionalEntityManager
37
- );
38
- updatedItemIds.push(item.id);
39
- }
40
- });
41
- }
42
-
43
- const itemIdsToDelete = existingItemIds.filter(id => !updatedItemIds.includes(id));
44
- await itemService.deleteMany(itemIdsToDelete);
45
- };
46
-
47
- export const handleParsedItem = async (
48
- parsedItem: Episode,
49
- channel: Channel,
50
- channelSeasonIndex: ChannelSeasonIndex,
51
- transactionalEntityManager: EntityManager
52
- ) => {
53
- const itemService = new ItemService();
54
- const itemDto = compatItemDto(parsedItem);
55
- const item = await itemService.update(channel, itemDto);
56
-
57
- await handleParsedItemAbout(parsedItem, item, transactionalEntityManager);
58
- await handleParsedItemChaptersFeed(parsedItem, item, transactionalEntityManager);
59
- await handleParsedItemChat(parsedItem, item, transactionalEntityManager);
60
-
61
- // // PTDO: add itemContentLinkService support after partytime adds chat support
62
- // const itemContentLinkService = new ItemContentLinkService();
63
- // const itemContentLinkDtos = compatItemContentLinkDtos(parsedItem);
64
- // if (itemContentLinkDtos.length) {
65
- // await itemContentLinkService.updateMany(item, itemContentLinkDtos);
66
- // } else {
67
- // await itemContentLinkService._deleteAll(item);
68
- // }
69
-
70
- await handleParsedItemDescription(parsedItem, item, transactionalEntityManager);
71
- await handleParsedItemEnclosure(parsedItem, item, transactionalEntityManager);
72
- await handleParsedItemImage(parsedItem, item, transactionalEntityManager);
73
- await handleParsedItemLicense(parsedItem, item, transactionalEntityManager);
74
- await handleParsedItemLocation(parsedItem, item, transactionalEntityManager);
75
- await handleParsedItemPerson(parsedItem, item, transactionalEntityManager);
76
- await handleParsedItemSeason(parsedItem, item, channelSeasonIndex, transactionalEntityManager);
77
- await handleParsedItemSeasonEpisode(parsedItem, item, transactionalEntityManager);
78
- await handleParsedItemSocialInteract(parsedItem, item, transactionalEntityManager);
79
- await handleParsedItemSoundbite(parsedItem, item, transactionalEntityManager);
80
- await handleParsedItemTranscript(parsedItem, item, transactionalEntityManager);
81
- await handleParsedItemTxt(parsedItem, item, transactionalEntityManager);
82
- await handleParsedItemValue(parsedItem, item, transactionalEntityManager);
83
-
84
- return item;
85
- };
@@ -1,13 +0,0 @@
1
- import { Episode } from "podcast-partytime";
2
- import { EntityManager, Item, ItemAboutService } from "podverse-orm";
3
- import { compatItemAboutDto } from "@parser/lib/compat/partytime/item";
4
-
5
- export const handleParsedItemAbout = async (
6
- parsedItem: Episode,
7
- item: Item,
8
- transactionalEntityManager: EntityManager
9
- ) => {
10
- const itemAboutService = new ItemAboutService(transactionalEntityManager);
11
- const itemAboutDto = compatItemAboutDto(parsedItem);
12
- await itemAboutService.update(item, itemAboutDto);
13
- };
@@ -1,14 +0,0 @@
1
- import { Episode } from "podcast-partytime";
2
- import { EntityManager, Item, ItemChaptersFeedService } from "podverse-orm";
3
- import { compatItemChaptersFeedDto } from "@parser/lib/compat/partytime/item";
4
- import { handleParsedOneData } from "../base/handleParsedOneData";
5
-
6
- export const handleParsedItemChaptersFeed = async (
7
- parsedItem: Episode,
8
- item: Item,
9
- transactionalEntityManager: EntityManager
10
- ) => {
11
- const itemChaptersFeedService = new ItemChaptersFeedService(transactionalEntityManager);
12
- const itemChaptersFeedDto = compatItemChaptersFeedDto(parsedItem);
13
- await handleParsedOneData(item, itemChaptersFeedService, itemChaptersFeedDto);
14
- };
@@ -1,14 +0,0 @@
1
- import { Episode } from "podcast-partytime";
2
- import { EntityManager, Item, ItemChatService } from "podverse-orm";
3
- import { compatItemChatDto } from "@parser/lib/compat/partytime/item";
4
- import { handleParsedOneData } from "../base/handleParsedOneData";
5
-
6
- export const handleParsedItemChat = async (
7
- parsedItem: Episode,
8
- item: Item,
9
- transactionalEntityManager: EntityManager
10
- ) => {
11
- const itemChatService = new ItemChatService(transactionalEntityManager);
12
- const itemChatDto = compatItemChatDto(parsedItem);
13
- await handleParsedOneData(item, itemChatService, itemChatDto);
14
- };
File without changes
@@ -1,14 +0,0 @@
1
- import { Episode } from "podcast-partytime";
2
- import { EntityManager, Item, ItemDescriptionService } from "podverse-orm";
3
- import { compatItemDescriptionDto } from "@parser/lib/compat/partytime/item";
4
- import { handleParsedOneData } from "../base/handleParsedOneData";
5
-
6
- export const handleParsedItemDescription = async (
7
- parsedItem: Episode,
8
- item: Item,
9
- transactionalEntityManager: EntityManager
10
- ) => {
11
- const itemDescriptionService = new ItemDescriptionService(transactionalEntityManager);
12
- const itemDescriptionDto = compatItemDescriptionDto(parsedItem);
13
- await handleParsedOneData(item, itemDescriptionService, itemDescriptionDto);
14
- };
@@ -1,35 +0,0 @@
1
- import { Episode } from "podcast-partytime";
2
- import { EntityManager, Item, ItemEnclosureService, ItemEnclosureSourceService,
3
- ItemEnclosureIntegrityService } from "podverse-orm";
4
- import { compatItemEnclosureDtos } from "@parser/lib/compat/partytime/item";
5
-
6
- export const handleParsedItemEnclosure = async (
7
- parsedItem: Episode,
8
- item: Item,
9
- transactionalEntityManager: EntityManager
10
- ) => {
11
- const itemEnclosureService = new ItemEnclosureService(transactionalEntityManager);
12
- const itemEnclosureDtos = compatItemEnclosureDtos(parsedItem);
13
-
14
- if (itemEnclosureDtos.length > 0) {
15
- for (const itemEnclosureDto of itemEnclosureDtos) {
16
- const item_enclosure = await itemEnclosureService.update(item, itemEnclosureDto.item_enclosure);
17
-
18
- const itemEnclosureSourceDtos = itemEnclosureDto.item_enclosure_sources;
19
- if (itemEnclosureSourceDtos.length > 0) {
20
- const itemEnclosureSourceService = new ItemEnclosureSourceService(transactionalEntityManager);
21
- await itemEnclosureSourceService.updateMany(item_enclosure, itemEnclosureSourceDtos);
22
- } else {
23
- await itemEnclosureService.deleteAll(item);
24
- }
25
-
26
- const itemEnclosureIntegrityDto = itemEnclosureDto.item_enclosure_integrity;
27
- if (itemEnclosureIntegrityDto) {
28
- const itemEnclosureIntegrityService = new ItemEnclosureIntegrityService(transactionalEntityManager);
29
- await itemEnclosureIntegrityService.update(item_enclosure, itemEnclosureIntegrityDto);
30
- }
31
- }
32
- } else {
33
- await itemEnclosureService.deleteAll(item);
34
- }
35
- };
@@ -1,14 +0,0 @@
1
- import { Episode } from "podcast-partytime";
2
- import { EntityManager, Item, ItemImageService } from "podverse-orm";
3
- import { compatItemImageDtos } from "@parser/lib/compat/partytime/item";
4
- import { handleParsedManyData } from "../base/handleParsedManyData";
5
-
6
- export const handleParsedItemImage = async (
7
- parsedItem: Episode,
8
- item: Item,
9
- transactionalEntityManager: EntityManager
10
- ) => {
11
- const itemImageService = new ItemImageService(transactionalEntityManager);
12
- const itemImageDtos = compatItemImageDtos(parsedItem);
13
- await handleParsedManyData(item, itemImageService, itemImageDtos);
14
- };
@@ -1,14 +0,0 @@
1
- import { Episode } from "podcast-partytime";
2
- import { EntityManager, Item, ItemLicenseService } from "podverse-orm";
3
- import { compatItemLicenseDto } from "@parser/lib/compat/partytime/item";
4
- import { handleParsedOneData } from "../base/handleParsedOneData";
5
-
6
- export const handleParsedItemLicense = async (
7
- parsedItem: Episode,
8
- item: Item,
9
- transactionalEntityManager: EntityManager
10
- ) => {
11
- const itemLicenseService = new ItemLicenseService(transactionalEntityManager);
12
- const itemLicenseDto = compatItemLicenseDto(parsedItem);
13
- await handleParsedOneData(item, itemLicenseService, itemLicenseDto);
14
- };
@@ -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
- };