node-csfd-api 4.3.3 → 5.0.0-next.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.
@@ -1,6 +1,53 @@
1
1
  const require_global_helper = require('./global.helper.js');
2
2
 
3
3
  //#region src/helpers/movie.helper.ts
4
+ const CREATOR_LABELS = {
5
+ en: {
6
+ directors: "Directed by",
7
+ writers: "Screenplay",
8
+ cinematography: "Cinematography",
9
+ music: "Composer",
10
+ actors: "Cast",
11
+ basedOn: "Based on",
12
+ producers: "Produced by",
13
+ filmEditing: "Editing",
14
+ costumeDesign: "Costumes",
15
+ productionDesign: "Production design",
16
+ casting: "Casting",
17
+ sound: "Sound",
18
+ makeup: "Make-up"
19
+ },
20
+ cs: {
21
+ directors: "Režie",
22
+ writers: "Scénář",
23
+ cinematography: "Kamera",
24
+ music: "Hudba",
25
+ actors: "Hrají",
26
+ basedOn: "Předloha",
27
+ producers: "Produkce",
28
+ filmEditing: "Střih",
29
+ costumeDesign: "Kostýmy",
30
+ productionDesign: "Scénografie",
31
+ casting: "Casting",
32
+ sound: "Zvuk",
33
+ makeup: "Masky"
34
+ },
35
+ sk: {
36
+ directors: "Réžia",
37
+ writers: "Scenár",
38
+ cinematography: "Kamera",
39
+ music: "Hudba",
40
+ actors: "Hrajú",
41
+ basedOn: "Predloha",
42
+ producers: "Produkcia",
43
+ filmEditing: "Strih",
44
+ costumeDesign: "Kostýmy",
45
+ productionDesign: "Scénografia",
46
+ casting: "Casting",
47
+ sound: "Zvuk",
48
+ makeup: "Masky"
49
+ }
50
+ };
4
51
  /**
5
52
  * Maps language-specific movie creator group labels.
6
53
  * @param language - The language code (e.g., 'en', 'cs')
@@ -8,54 +55,7 @@ const require_global_helper = require('./global.helper.js');
8
55
  * @returns The localized label for the creator group
9
56
  */
10
57
  const getLocalizedCreatorLabel = (language, key) => {
11
- const labels = {
12
- en: {
13
- directors: "Directed by",
14
- writers: "Screenplay",
15
- cinematography: "Cinematography",
16
- music: "Composer",
17
- actors: "Cast",
18
- basedOn: "Based on",
19
- producers: "Produced by",
20
- filmEditing: "Editing",
21
- costumeDesign: "Costumes",
22
- productionDesign: "Production design",
23
- casting: "Casting",
24
- sound: "Sound",
25
- makeup: "Make-up"
26
- },
27
- cs: {
28
- directors: "Režie",
29
- writers: "Scénář",
30
- cinematography: "Kamera",
31
- music: "Hudba",
32
- actors: "Hrají",
33
- basedOn: "Předloha",
34
- producers: "Produkce",
35
- filmEditing: "Střih",
36
- costumeDesign: "Kostýmy",
37
- productionDesign: "Scénografie",
38
- casting: "Casting",
39
- sound: "Zvuk",
40
- makeup: "Masky"
41
- },
42
- sk: {
43
- directors: "Réžia",
44
- writers: "Scenár",
45
- cinematography: "Kamera",
46
- music: "Hudba",
47
- actors: "Hrajú",
48
- basedOn: "Predloha",
49
- producers: "Produkcia",
50
- filmEditing: "Strih",
51
- costumeDesign: "Kostýmy",
52
- productionDesign: "Scénografia",
53
- casting: "Casting",
54
- sound: "Zvuk",
55
- makeup: "Masky"
56
- }
57
- };
58
- return (labels[language || "cs"] || labels["cs"])[key];
58
+ return (CREATOR_LABELS[language || "cs"] || CREATOR_LABELS["cs"])[key];
59
59
  };
60
60
  const getMovieTitle = (el) => {
61
61
  return el.querySelector("h1").innerText.split(`(`)[0].trim();
@@ -178,7 +178,7 @@ const getMovieCreators = (el, options) => {
178
178
  return creators;
179
179
  };
180
180
  const getMovieType = (el) => {
181
- return el.querySelector(".film-header-name .type")?.innerText?.replace(/[{()}]/g, "") || "film";
181
+ return require_global_helper.parseFilmType(el.querySelector(".film-header-name .type")?.innerText?.replace(/[{()}]/g, "") || "film");
182
182
  };
183
183
  const getMovieVods = (el) => {
184
184
  let vods = [];
@@ -209,8 +209,9 @@ const getMoviePremieres = (el) => {
209
209
  for (const premiereNode of premiereNodes) {
210
210
  const title = premiereNode.querySelector("p + span").attributes.title;
211
211
  if (title) {
212
- const [date, ...company] = title?.split(" ");
213
- premiere.push({
212
+ const [dateRaw, ...company] = title?.split(" ");
213
+ const date = require_global_helper.parseDate(dateRaw);
214
+ if (date) premiere.push({
214
215
  country: premiereNode.querySelector(".flag")?.attributes.title || null,
215
216
  format: premiereNode.querySelector("p").textContent.trim()?.split(" od")[0],
216
217
  date,
@@ -1 +1 @@
1
- {"version":3,"file":"movie.helper.js","names":["getColor","parseISO8601Duration","addProtocol","parseIdFromUrl"],"sources":["../../src/helpers/movie.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating } from '../dto/global';\nimport {\n CSFDBoxContent,\n CSFDCreatorGroups,\n CSFDCreatorGroupsEnglish,\n CSFDCreatorGroupsSlovak,\n CSFDCreators,\n CSFDGenres,\n CSFDMovieCreator,\n CSFDMovieListItem,\n CSFDPremiere,\n CSFDTitlesOther,\n CSFDVod,\n CSFDVodService,\n MovieJsonLd\n} from '../dto/movie';\nimport { CSFDOptions } from '../types';\nimport { addProtocol, getColor, parseISO8601Duration, parseIdFromUrl } from './global.helper';\n\n/**\n * Maps language-specific movie creator group labels.\n * @param language - The language code (e.g., 'en', 'cs')\n * @param key - The key of the creator group (e.g., 'directors', 'writers')\n * @returns The localized label for the creator group\n */\nexport const getLocalizedCreatorLabel = (\n language: string | undefined,\n key:\n | 'directors'\n | 'writers'\n | 'cinematography'\n | 'music'\n | 'actors'\n | 'basedOn'\n | 'producers'\n | 'filmEditing'\n | 'costumeDesign'\n | 'productionDesign'\n | 'casting'\n | 'sound'\n | 'makeup'\n): CSFDCreatorGroups | CSFDCreatorGroupsEnglish | CSFDCreatorGroupsSlovak => {\n const labels: Record<\n string,\n Record<string, CSFDCreatorGroups | CSFDCreatorGroupsEnglish | CSFDCreatorGroupsSlovak>\n > = {\n en: {\n directors: 'Directed by',\n writers: 'Screenplay',\n cinematography: 'Cinematography',\n music: 'Composer',\n actors: 'Cast',\n basedOn: 'Based on',\n producers: 'Produced by',\n filmEditing: 'Editing',\n costumeDesign: 'Costumes',\n productionDesign: 'Production design',\n casting: 'Casting',\n sound: 'Sound',\n makeup: 'Make-up'\n },\n cs: {\n directors: 'Režie',\n writers: 'Scénář',\n cinematography: 'Kamera',\n music: 'Hudba',\n actors: 'Hrají',\n basedOn: 'Předloha',\n producers: 'Produkce',\n filmEditing: 'Střih',\n costumeDesign: 'Kostýmy',\n productionDesign: 'Scénografie',\n casting: 'Casting',\n sound: 'Zvuk',\n makeup: 'Masky'\n },\n sk: {\n directors: 'Réžia',\n writers: 'Scenár',\n cinematography: 'Kamera',\n music: 'Hudba',\n actors: 'Hrajú',\n basedOn: 'Predloha',\n producers: 'Produkcia',\n filmEditing: 'Strih',\n costumeDesign: 'Kostýmy',\n productionDesign: 'Scénografia',\n casting: 'Casting',\n sound: 'Zvuk',\n makeup: 'Masky'\n }\n };\n\n const lang = language || 'cs'; // Default to Czech\n return (labels[lang] || labels['cs'])[key];\n};\n\nexport const getMovieId = (el: HTMLElement): number => {\n const url = el.querySelector('.tabs .tab-nav-list a').attributes.href;\n return parseIdFromUrl(url);\n};\n\nexport const getMovieTitle = (el: HTMLElement): string => {\n return el.querySelector('h1').innerText.split(`(`)[0].trim();\n};\n\nexport const getMovieGenres = (el: HTMLElement): CSFDGenres[] => {\n const genresRaw = el.querySelector('.genres').textContent;\n return genresRaw.split(' / ') as CSFDGenres[];\n};\n\nexport const getMovieOrigins = (el: HTMLElement): string[] => {\n const originsRaw = el.querySelector('.origin').textContent;\n const origins = originsRaw.split(',')[0];\n return origins.split(' / ');\n};\n\nexport const getMovieColorRating = (bodyClasses: string[]): CSFDColorRating => {\n return getColor(bodyClasses[1]);\n};\n\nexport const getMovieRating = (el: HTMLElement): number => {\n const ratingRaw = el.querySelector('.film-rating-average').textContent;\n const rating = ratingRaw?.replace(/%/g, '').trim();\n const ratingInt = parseInt(rating);\n\n if (Number.isInteger(ratingInt)) {\n return ratingInt;\n } else {\n return null;\n }\n};\n\nexport const getMovieRatingCount = (el: HTMLElement): number => {\n const ratingCountRaw = el.querySelector('.box-rating-container .counter')?.textContent;\n const ratingCount = +ratingCountRaw?.replace(/[(\\s)]/g, '');\n if (Number.isInteger(ratingCount)) {\n return ratingCount;\n } else {\n return null;\n }\n};\n\nexport const getMovieYear = (jsonLd: MovieJsonLd | null): number => {\n if (jsonLd && jsonLd.dateCreated) {\n return +jsonLd.dateCreated;\n }\n return null;\n};\n\nexport const getMovieDuration = (jsonLd: MovieJsonLd | null, el: HTMLElement): number => {\n if (jsonLd && jsonLd.duration) {\n try {\n return parseISO8601Duration(jsonLd.duration);\n } catch (e) {\n // ignore\n }\n }\n\n try {\n const origin = el.querySelector('.origin').innerText;\n const timeString = origin.split(',');\n if (timeString.length > 2) {\n // Get last time elelment\n const timeString2 = timeString.pop().trim();\n // Clean it\n const timeRaw = timeString2.split('(')[0].trim();\n // Split by minutes and hours\n const hoursMinsRaw = timeRaw.split('min')[0];\n const hoursMins = hoursMinsRaw.split('h');\n // Resolve hours + minutes format\n const duration = hoursMins.length > 1 ? +hoursMins[0] * 60 + +hoursMins[1] : +hoursMins[0];\n return duration;\n } else {\n return null;\n }\n } catch (error) {\n return null;\n }\n};\n\nexport const getMovieTitlesOther = (el: HTMLElement): CSFDTitlesOther[] => {\n const namesNode = el.querySelectorAll('.film-names li');\n\n if (!namesNode.length) {\n return [];\n }\n\n const titlesOther = namesNode.map((el) => {\n const country = el.querySelector('img.flag').attributes.alt;\n const title = el.textContent.trim().split('\\n')[0];\n\n if (country && title) {\n return {\n country,\n title\n };\n } else {\n return null;\n }\n });\n\n return titlesOther.filter((x) => x);\n};\n\nexport const getMoviePoster = (el: HTMLElement | null): string => {\n const poster = el.querySelector('.film-posters img');\n // Resolve empty image\n if (poster) {\n if (poster.classNames?.includes('empty-image')) {\n return null;\n } else {\n // Full sized image (not thumb)\n const imageThumb = poster.attributes.src.split('?')[0];\n const image = imageThumb.replace(/\\/w140\\//, '/w1080/');\n return addProtocol(image);\n }\n } else {\n return null;\n }\n};\n\nexport const getMovieRandomPhoto = (el: HTMLElement | null): string => {\n const imageNode = el.querySelector('.gallery-item picture img');\n const image = imageNode?.attributes?.src;\n if (image) {\n return image.replace(/\\/w663\\//, '/w1326/');\n } else {\n return null;\n }\n};\n\nexport const getMovieTrivia = (el: HTMLElement | null): string[] => {\n const triviaNodes = el.querySelectorAll('.article-trivia ul li');\n if (triviaNodes?.length) {\n return triviaNodes.map((node) => node.textContent.trim().replace(/(\\r\\n|\\n|\\r|\\t)/gm, ''));\n } else {\n return null;\n }\n};\n\nexport const getMovieDescriptions = (el: HTMLElement): string[] => {\n return el\n .querySelectorAll('.body--plots .plot-full p, .body--plots .plots .plots-item p')\n .map((movie) => movie.textContent?.trim().replace(/(\\r\\n|\\n|\\r|\\t)/gm, ''));\n};\n\nconst parseMoviePeople = (el: HTMLElement): CSFDMovieCreator[] => {\n const people = el.querySelectorAll('a');\n return (\n people\n // Filter out \"more\" links\n .filter((x) => x.classNames.length === 0)\n .map((person) => {\n return {\n id: parseIdFromUrl(person.attributes.href),\n name: person.innerText.trim(),\n url: `https://www.csfd.cz${person.attributes.href}`\n };\n })\n );\n};\n\n// export const getMovieGroup = (el: HTMLElement, group: CSFDCreatorGroups | CSFDCreatorGroupsEnglish | CSFDCreatorGroupsSlovak): CSFDMovieCreator[] => {\n// const creators = el.querySelectorAll('.creators h4');\n// const element = creators.filter((elem) => elem.textContent.trim().includes(group))[0];\n// if (element?.parentNode) {\n// return parseMoviePeople(element.parentNode as HTMLElement);\n// } else {\n// return [];\n// }\n// };\n\nexport const getMovieCreators = (el: HTMLElement, options?: CSFDOptions): CSFDCreators => {\n const creators: CSFDCreators = {\n directors: [],\n writers: [],\n cinematography: [],\n music: [],\n actors: [],\n basedOn: [],\n producers: [],\n filmEditing: [],\n costumeDesign: [],\n productionDesign: []\n };\n\n const groups = el.querySelectorAll('.creators h4');\n\n const keys = [\n 'directors',\n 'writers',\n 'cinematography',\n 'music',\n 'actors',\n 'basedOn',\n 'producers',\n 'filmEditing',\n 'costumeDesign',\n 'productionDesign'\n ] as const;\n\n const localizedLabels = keys.map((key) => ({\n key,\n label: getLocalizedCreatorLabel(options?.language, key) as string\n }));\n\n for (const group of groups) {\n const text = group.textContent.trim();\n for (const { key, label } of localizedLabels) {\n if (text.includes(label)) {\n if (group.parentNode) {\n creators[key] = parseMoviePeople(group.parentNode as HTMLElement);\n }\n break;\n }\n }\n }\n\n return creators;\n};\n\nexport const getMovieType = (el: HTMLElement): string => {\n const type = el.querySelector('.film-header-name .type');\n return type?.innerText?.replace(/[{()}]/g, '') || 'film';\n};\n\nexport const getMovieVods = (el: HTMLElement | null): CSFDVod[] => {\n let vods: CSFDVod[] = [];\n if (el) {\n const buttonsVod = el.querySelectorAll('.box-buttons-vod .vod-badge a');\n vods = buttonsVod.map((btn) => {\n return {\n title: btn.textContent.trim() as CSFDVodService,\n url: btn.attributes.href\n };\n });\n }\n return vods.length ? vods : [];\n};\n\n// Get box content\nconst getBoxContent = (el: HTMLElement, box: string): HTMLElement => {\n const headers = el.querySelectorAll('section.box .box-header');\n return headers.find((header) => header.querySelector('h3')?.textContent.trim().includes(box))\n ?.parentNode;\n};\n\nexport const getMovieBoxMovies = (\n el: HTMLElement,\n boxName: CSFDBoxContent\n): CSFDMovieListItem[] => {\n const movieListItem: CSFDMovieListItem[] = [];\n const box = getBoxContent(el, boxName);\n const movieTitleNodes = box?.querySelectorAll('.article-header .film-title-name');\n if (movieTitleNodes?.length) {\n for (const item of movieTitleNodes) {\n movieListItem.push({\n id: parseIdFromUrl(item.attributes.href),\n title: item.textContent.trim(),\n url: `https://www.csfd.cz${item.attributes.href}`\n });\n }\n }\n return movieListItem;\n};\n\nexport const getMoviePremieres = (el: HTMLElement): CSFDPremiere[] => {\n const premiereNodes = el.querySelectorAll('.box-premieres li');\n const premiere: CSFDPremiere[] = [];\n for (const premiereNode of premiereNodes) {\n const title = premiereNode.querySelector('p + span').attributes.title;\n\n if (title) {\n const [date, ...company] = title?.split(' ');\n\n premiere.push({\n country: premiereNode.querySelector('.flag')?.attributes.title || null,\n format: premiereNode.querySelector('p').textContent.trim()?.split(' od')[0],\n date,\n company: company.join(' ')\n });\n }\n }\n return premiere;\n};\n\nexport const getMovieTags = (el: HTMLElement): string[] => {\n const tagsRaw = el.querySelectorAll('.box-content a[href*=\"/tag/\"]');\n return tagsRaw.map((tag) => tag.textContent);\n};\n"],"mappings":";;;;;;;;;AA0BA,MAAa,4BACX,UACA,QAc2E;CAC3E,MAAM,SAGF;EACF,IAAI;GACF,WAAW;GACX,SAAS;GACT,gBAAgB;GAChB,OAAO;GACP,QAAQ;GACR,SAAS;GACT,WAAW;GACX,aAAa;GACb,eAAe;GACf,kBAAkB;GAClB,SAAS;GACT,OAAO;GACP,QAAQ;GACT;EACD,IAAI;GACF,WAAW;GACX,SAAS;GACT,gBAAgB;GAChB,OAAO;GACP,QAAQ;GACR,SAAS;GACT,WAAW;GACX,aAAa;GACb,eAAe;GACf,kBAAkB;GAClB,SAAS;GACT,OAAO;GACP,QAAQ;GACT;EACD,IAAI;GACF,WAAW;GACX,SAAS;GACT,gBAAgB;GAChB,OAAO;GACP,QAAQ;GACR,SAAS;GACT,WAAW;GACX,aAAa;GACb,eAAe;GACf,kBAAkB;GAClB,SAAS;GACT,OAAO;GACP,QAAQ;GACT;EACF;AAGD,SAAQ,OADK,YAAY,SACD,OAAO,OAAO;;AAQxC,MAAa,iBAAiB,OAA4B;AACxD,QAAO,GAAG,cAAc,KAAK,CAAC,UAAU,MAAM,IAAI,CAAC,GAAG,MAAM;;AAG9D,MAAa,kBAAkB,OAAkC;AAE/D,QADkB,GAAG,cAAc,UAAU,CAAC,YAC7B,MAAM,MAAM;;AAG/B,MAAa,mBAAmB,OAA8B;AAG5D,QAFmB,GAAG,cAAc,UAAU,CAAC,YACpB,MAAM,IAAI,CAAC,GACvB,MAAM,MAAM;;AAG7B,MAAa,uBAAuB,gBAA2C;AAC7E,QAAOA,+BAAS,YAAY,GAAG;;AAGjC,MAAa,kBAAkB,OAA4B;CAEzD,MAAM,SADY,GAAG,cAAc,uBAAuB,C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AAe;EACxC,MAAM,QAAQ,aAAa,cAAc,WAAW,CAAC,WAAW;AAEhE,MAAI,OAAO;GACT,MAAM,CAAC,MAAM,GAAG,WAAW,OAAO,MAAM,IAAI;AAE5C,YAAS,KAAK;IACZ,SAAS,aAAa,cAAc,QAAQ,EAAE,WAAW,SAAS;IAClE,QAAQ,aAAa,cAAc,IAAI,CAAC,YAAY,MAAM,EAAE,MAAM,MAAM,CAAC;IACzE;IACA,SAAS,QAAQ,KAAK,IAAI;IAC3B,CAAC;;;AAGN,QAAO;;AAGT,MAAa,gBAAgB,OAA8B;AAEzD,QADgB,GAAG,iBAAiB,kCAAgC,CACrD,KAAK,QAAQ,IAAI,YAAY"}
1
+ {"version":3,"file":"movie.helper.js","names":["getColor","parseISO8601Duration","addProtocol","parseIdFromUrl","parseFilmType","parseDate"],"sources":["../../src/helpers/movie.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating, CSFDFilmTypes } from '../dto/global';\nimport {\n CSFDBoxContent,\n CSFDCreatorGroups,\n CSFDCreatorGroupsEnglish,\n CSFDCreatorGroupsSlovak,\n CSFDCreators,\n CSFDGenres,\n CSFDMovieCreator,\n CSFDMovieListItem,\n CSFDPremiere,\n CSFDTitlesOther,\n CSFDVod,\n CSFDVodService,\n MovieJsonLd\n} from '../dto/movie';\nimport { CSFDOptions } from '../types';\nimport {\n addProtocol,\n getColor,\n parseDate,\n parseFilmType,\n parseISO8601Duration,\n parseIdFromUrl\n} from './global.helper';\n\nconst CREATOR_LABELS: Record<\n string,\n Record<string, CSFDCreatorGroups | CSFDCreatorGroupsEnglish | CSFDCreatorGroupsSlovak>\n> = {\n en: {\n directors: 'Directed by',\n writers: 'Screenplay',\n cinematography: 'Cinematography',\n music: 'Composer',\n actors: 'Cast',\n basedOn: 'Based on',\n producers: 'Produced by',\n filmEditing: 'Editing',\n costumeDesign: 'Costumes',\n productionDesign: 'Production design',\n casting: 'Casting',\n sound: 'Sound',\n makeup: 'Make-up'\n },\n cs: {\n directors: 'Režie',\n writers: 'Scénář',\n cinematography: 'Kamera',\n music: 'Hudba',\n actors: 'Hrají',\n basedOn: 'Předloha',\n producers: 'Produkce',\n filmEditing: 'Střih',\n costumeDesign: 'Kostýmy',\n productionDesign: 'Scénografie',\n casting: 'Casting',\n sound: 'Zvuk',\n makeup: 'Masky'\n },\n sk: {\n directors: 'Réžia',\n writers: 'Scenár',\n cinematography: 'Kamera',\n music: 'Hudba',\n actors: 'Hrajú',\n basedOn: 'Predloha',\n producers: 'Produkcia',\n filmEditing: 'Strih',\n costumeDesign: 'Kostýmy',\n productionDesign: 'Scénografia',\n casting: 'Casting',\n sound: 'Zvuk',\n makeup: 'Masky'\n }\n};\n\n/**\n * Maps language-specific movie creator group labels.\n * @param language - The language code (e.g., 'en', 'cs')\n * @param key - The key of the creator group (e.g., 'directors', 'writers')\n * @returns The localized label for the creator group\n */\nexport const getLocalizedCreatorLabel = (\n language: string | undefined,\n key:\n | 'directors'\n | 'writers'\n | 'cinematography'\n | 'music'\n | 'actors'\n | 'basedOn'\n | 'producers'\n | 'filmEditing'\n | 'costumeDesign'\n | 'productionDesign'\n | 'casting'\n | 'sound'\n | 'makeup'\n): CSFDCreatorGroups | CSFDCreatorGroupsEnglish | CSFDCreatorGroupsSlovak => {\n const lang = language || 'cs'; // Default to Czech\n return (CREATOR_LABELS[lang] || CREATOR_LABELS['cs'])[key];\n};\n\nexport const getMovieId = (el: HTMLElement): number => {\n const url = el.querySelector('.tabs .tab-nav-list a').attributes.href;\n return parseIdFromUrl(url);\n};\n\nexport const getMovieTitle = (el: HTMLElement): string => {\n return el.querySelector('h1').innerText.split(`(`)[0].trim();\n};\n\nexport const getMovieGenres = (el: HTMLElement): CSFDGenres[] => {\n const genresRaw = el.querySelector('.genres').textContent;\n return genresRaw.split(' / ') as CSFDGenres[];\n};\n\nexport const getMovieOrigins = (el: HTMLElement): string[] => {\n const originsRaw = el.querySelector('.origin').textContent;\n const origins = originsRaw.split(',')[0];\n return origins.split(' / ');\n};\n\nexport const getMovieColorRating = (bodyClasses: string[]): CSFDColorRating => {\n return getColor(bodyClasses[1]);\n};\n\nexport const getMovieRating = (el: HTMLElement): number => {\n const ratingRaw = el.querySelector('.film-rating-average').textContent;\n const rating = ratingRaw?.replace(/%/g, '').trim();\n const ratingInt = parseInt(rating);\n\n if (Number.isInteger(ratingInt)) {\n return ratingInt;\n } else {\n return null;\n }\n};\n\nexport const getMovieRatingCount = (el: HTMLElement): number => {\n const ratingCountRaw = el.querySelector('.box-rating-container .counter')?.textContent;\n const ratingCount = +ratingCountRaw?.replace(/[(\\s)]/g, '');\n if (Number.isInteger(ratingCount)) {\n return ratingCount;\n } else {\n return null;\n }\n};\n\nexport const getMovieYear = (jsonLd: MovieJsonLd | null): number => {\n if (jsonLd && jsonLd.dateCreated) {\n return +jsonLd.dateCreated;\n }\n return null;\n};\n\nexport const getMovieDuration = (jsonLd: MovieJsonLd | null, el: HTMLElement): number => {\n if (jsonLd && jsonLd.duration) {\n try {\n return parseISO8601Duration(jsonLd.duration);\n } catch (e) {\n // ignore\n }\n }\n\n try {\n const origin = el.querySelector('.origin').innerText;\n const timeString = origin.split(',');\n if (timeString.length > 2) {\n // Get last time elelment\n const timeString2 = timeString.pop().trim();\n // Clean it\n const timeRaw = timeString2.split('(')[0].trim();\n // Split by minutes and hours\n const hoursMinsRaw = timeRaw.split('min')[0];\n const hoursMins = hoursMinsRaw.split('h');\n // Resolve hours + minutes format\n const duration = hoursMins.length > 1 ? +hoursMins[0] * 60 + +hoursMins[1] : +hoursMins[0];\n return duration;\n } else {\n return null;\n }\n } catch (error) {\n return null;\n }\n};\n\nexport const getMovieTitlesOther = (el: HTMLElement): CSFDTitlesOther[] => {\n const namesNode = el.querySelectorAll('.film-names li');\n\n if (!namesNode.length) {\n return [];\n }\n\n const titlesOther = namesNode.map((el) => {\n const country = el.querySelector('img.flag').attributes.alt;\n const title = el.textContent.trim().split('\\n')[0];\n\n if (country && title) {\n return {\n country,\n title\n };\n } else {\n return null;\n }\n });\n\n return titlesOther.filter((x) => x);\n};\n\nexport const getMoviePoster = (el: HTMLElement | null): string => {\n const poster = el.querySelector('.film-posters img');\n // Resolve empty image\n if (poster) {\n if (poster.classNames?.includes('empty-image')) {\n return null;\n } else {\n // Full sized image (not thumb)\n const imageThumb = poster.attributes.src.split('?')[0];\n const image = imageThumb.replace(/\\/w140\\//, '/w1080/');\n return addProtocol(image);\n }\n } else {\n return null;\n }\n};\n\nexport const getMovieRandomPhoto = (el: HTMLElement | null): string => {\n const imageNode = el.querySelector('.gallery-item picture img');\n const image = imageNode?.attributes?.src;\n if (image) {\n return image.replace(/\\/w663\\//, '/w1326/');\n } else {\n return null;\n }\n};\n\nexport const getMovieTrivia = (el: HTMLElement | null): string[] => {\n const triviaNodes = el.querySelectorAll('.article-trivia ul li');\n if (triviaNodes?.length) {\n return triviaNodes.map((node) => node.textContent.trim().replace(/(\\r\\n|\\n|\\r|\\t)/gm, ''));\n } else {\n return null;\n }\n};\n\nexport const getMovieDescriptions = (el: HTMLElement): string[] => {\n return el\n .querySelectorAll('.body--plots .plot-full p, .body--plots .plots .plots-item p')\n .map((movie) => movie.textContent?.trim().replace(/(\\r\\n|\\n|\\r|\\t)/gm, ''));\n};\n\nconst parseMoviePeople = (el: HTMLElement): CSFDMovieCreator[] => {\n const people = el.querySelectorAll('a');\n return (\n people\n // Filter out \"more\" links\n .filter((x) => x.classNames.length === 0)\n .map((person) => {\n return {\n id: parseIdFromUrl(person.attributes.href),\n name: person.innerText.trim(),\n url: `https://www.csfd.cz${person.attributes.href}`\n };\n })\n );\n};\n\n// export const getMovieGroup = (el: HTMLElement, group: CSFDCreatorGroups | CSFDCreatorGroupsEnglish | CSFDCreatorGroupsSlovak): CSFDMovieCreator[] => {\n// const creators = el.querySelectorAll('.creators h4');\n// const element = creators.filter((elem) => elem.textContent.trim().includes(group))[0];\n// if (element?.parentNode) {\n// return parseMoviePeople(element.parentNode as HTMLElement);\n// } else {\n// return [];\n// }\n// };\n\nexport const getMovieCreators = (el: HTMLElement, options?: CSFDOptions): CSFDCreators => {\n const creators: CSFDCreators = {\n directors: [],\n writers: [],\n cinematography: [],\n music: [],\n actors: [],\n basedOn: [],\n producers: [],\n filmEditing: [],\n costumeDesign: [],\n productionDesign: []\n };\n\n const groups = el.querySelectorAll('.creators h4');\n\n const keys = [\n 'directors',\n 'writers',\n 'cinematography',\n 'music',\n 'actors',\n 'basedOn',\n 'producers',\n 'filmEditing',\n 'costumeDesign',\n 'productionDesign'\n ] as const;\n\n const localizedLabels = keys.map((key) => ({\n key,\n label: getLocalizedCreatorLabel(options?.language, key) as string\n }));\n\n for (const group of groups) {\n const text = group.textContent.trim();\n for (const { key, label } of localizedLabels) {\n if (text.includes(label)) {\n if (group.parentNode) {\n creators[key] = parseMoviePeople(group.parentNode as HTMLElement);\n }\n break;\n }\n }\n }\n\n return creators;\n};\n\nexport const getMovieType = (el: HTMLElement): CSFDFilmTypes => {\n const type = el.querySelector('.film-header-name .type');\n return parseFilmType(type?.innerText?.replace(/[{()}]/g, '') || 'film');\n};\n\nexport const getMovieVods = (el: HTMLElement | null): CSFDVod[] => {\n let vods: CSFDVod[] = [];\n if (el) {\n const buttonsVod = el.querySelectorAll('.box-buttons-vod .vod-badge a');\n vods = buttonsVod.map((btn) => {\n return {\n title: btn.textContent.trim() as CSFDVodService,\n url: btn.attributes.href\n };\n });\n }\n return vods.length ? vods : [];\n};\n\n// Get box content\nconst getBoxContent = (el: HTMLElement, box: string): HTMLElement => {\n const headers = el.querySelectorAll('section.box .box-header');\n return headers.find((header) => header.querySelector('h3')?.textContent.trim().includes(box))\n ?.parentNode;\n};\n\nexport const getMovieBoxMovies = (\n el: HTMLElement,\n boxName: CSFDBoxContent\n): CSFDMovieListItem[] => {\n const movieListItem: CSFDMovieListItem[] = [];\n const box = getBoxContent(el, boxName);\n const movieTitleNodes = box?.querySelectorAll('.article-header .film-title-name');\n if (movieTitleNodes?.length) {\n for (const item of movieTitleNodes) {\n movieListItem.push({\n id: parseIdFromUrl(item.attributes.href),\n title: item.textContent.trim(),\n url: `https://www.csfd.cz${item.attributes.href}`\n });\n }\n }\n return movieListItem;\n};\n\nexport const getMoviePremieres = (el: HTMLElement): CSFDPremiere[] => {\n const premiereNodes = el.querySelectorAll('.box-premieres li');\n const premiere: CSFDPremiere[] = [];\n for (const premiereNode of premiereNodes) {\n const title = premiereNode.querySelector('p + span').attributes.title;\n\n if (title) {\n const [dateRaw, ...company] = title?.split(' ');\n const date = parseDate(dateRaw);\n\n if (date) {\n premiere.push({\n country: premiereNode.querySelector('.flag')?.attributes.title || null,\n format: premiereNode.querySelector('p').textContent.trim()?.split(' od')[0],\n date,\n company: company.join(' ')\n });\n }\n }\n }\n return premiere;\n};\n\nexport const getMovieTags = (el: HTMLElement): string[] => {\n const tagsRaw = el.querySelectorAll('.box-content a[href*=\"/tag/\"]');\n return tagsRaw.map((tag) => tag.textContent);\n};\n"],"mappings":";;;AA2BA,MAAM,iBAGF;CACF,IAAI;EACF,WAAW;EACX,SAAS;EACT,gBAAgB;EAChB,OAAO;EACP,QAAQ;EACR,SAAS;EACT,WAAW;EACX,aAAa;EACb,eAAe;EACf,kBAAkB;EAClB,SAAS;EACT,OAAO;EACP,QAAQ;EACT;CACD,IAAI;EACF,WAAW;EACX,SAAS;EACT,gBAAgB;EAChB,OAAO;EACP,QAAQ;EACR,SAAS;EACT,WAAW;EACX,aAAa;EACb,eAAe;EACf,kBAAkB;EAClB,SAAS;EACT,OAAO;EACP,QAAQ;EACT;CACD,IAAI;EACF,WAAW;EACX,SAAS;EACT,gBAAgB;EAChB,OAAO;EACP,QAAQ;EACR,SAAS;EACT,WAAW;EACX,aAAa;EACb,eAAe;EACf,kBAAkB;EAClB,SAAS;EACT,OAAO;EACP,QAAQ;EACT;CACF;;;;;;;AAQD,MAAa,4BACX,UACA,QAc2E;AAE3E,SAAQ,eADK,YAAY,SACO,eAAe,OAAO;;AAQxD,MAAa,iBAAiB,OAA4B;A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,IACA,YACwB;CACxB,MAAM,gBAAqC,EAAE;CAE7C,MAAM,kBADM,cAAc,IAAI,QAAQ,EACT,iBAAiB,mCAAmC;AACjF,KAAI,iBAAiB,OACnB,MAAK,MAAM,QAAQ,gBACjB,eAAc,KAAK;EACjB,IAAID,qCAAe,KAAK,WAAW,KAAK;EACxC,OAAO,KAAK,YAAY,MAAM;EAC9B,KAAK,sBAAsB,KAAK,WAAW;EAC5C,CAAC;AAGN,QAAO;;AAGT,MAAa,qBAAqB,OAAoC;CACpE,MAAM,gBAAgB,GAAG,iBAAiB,oBAAoB;CAC9D,MAAM,WAA2B,EAAE;AACnC,MAAK,MAAM,gBAAgB,eAAe;EACxC,MAAM,QAAQ,aAAa,cAAc,WAAW,CAAC,WAAW;AAEhE,MAAI,OAAO;GACT,MAAM,CAAC,SAAS,GAAG,WAAW,OAAO,MAAM,IAAI;GAC/C,MAAM,OAAOE,gCAAU,QAAQ;AAE/B,OAAI,KACF,UAAS,KAAK;IACZ,SAAS,aAAa,cAAc,QAAQ,EAAE,WAAW,SAAS;IAClE,QAAQ,aAAa,cAAc,IAAI,CAAC,YAAY,MAAM,EAAE,MAAM,MAAM,CAAC;IACzE;IACA,SAAS,QAAQ,KAAK,IAAI;IAC3B,CAAC;;;AAIR,QAAO;;AAGT,MAAa,gBAAgB,OAA8B;AAEzD,QADgB,GAAG,iBAAiB,kCAAgC,CACrD,KAAK,QAAQ,IAAI,YAAY"}
@@ -1,6 +1,53 @@
1
- import { addProtocol, getColor, parseISO8601Duration, parseIdFromUrl } from "./global.helper.mjs";
1
+ import { addProtocol, getColor, parseDate, parseFilmType, parseISO8601Duration, parseIdFromUrl } from "./global.helper.mjs";
2
2
 
3
3
  //#region src/helpers/movie.helper.ts
4
+ const CREATOR_LABELS = {
5
+ en: {
6
+ directors: "Directed by",
7
+ writers: "Screenplay",
8
+ cinematography: "Cinematography",
9
+ music: "Composer",
10
+ actors: "Cast",
11
+ basedOn: "Based on",
12
+ producers: "Produced by",
13
+ filmEditing: "Editing",
14
+ costumeDesign: "Costumes",
15
+ productionDesign: "Production design",
16
+ casting: "Casting",
17
+ sound: "Sound",
18
+ makeup: "Make-up"
19
+ },
20
+ cs: {
21
+ directors: "Režie",
22
+ writers: "Scénář",
23
+ cinematography: "Kamera",
24
+ music: "Hudba",
25
+ actors: "Hrají",
26
+ basedOn: "Předloha",
27
+ producers: "Produkce",
28
+ filmEditing: "Střih",
29
+ costumeDesign: "Kostýmy",
30
+ productionDesign: "Scénografie",
31
+ casting: "Casting",
32
+ sound: "Zvuk",
33
+ makeup: "Masky"
34
+ },
35
+ sk: {
36
+ directors: "Réžia",
37
+ writers: "Scenár",
38
+ cinematography: "Kamera",
39
+ music: "Hudba",
40
+ actors: "Hrajú",
41
+ basedOn: "Predloha",
42
+ producers: "Produkcia",
43
+ filmEditing: "Strih",
44
+ costumeDesign: "Kostýmy",
45
+ productionDesign: "Scénografia",
46
+ casting: "Casting",
47
+ sound: "Zvuk",
48
+ makeup: "Masky"
49
+ }
50
+ };
4
51
  /**
5
52
  * Maps language-specific movie creator group labels.
6
53
  * @param language - The language code (e.g., 'en', 'cs')
@@ -8,54 +55,7 @@ import { addProtocol, getColor, parseISO8601Duration, parseIdFromUrl } from "./g
8
55
  * @returns The localized label for the creator group
9
56
  */
10
57
  const getLocalizedCreatorLabel = (language, key) => {
11
- const labels = {
12
- en: {
13
- directors: "Directed by",
14
- writers: "Screenplay",
15
- cinematography: "Cinematography",
16
- music: "Composer",
17
- actors: "Cast",
18
- basedOn: "Based on",
19
- producers: "Produced by",
20
- filmEditing: "Editing",
21
- costumeDesign: "Costumes",
22
- productionDesign: "Production design",
23
- casting: "Casting",
24
- sound: "Sound",
25
- makeup: "Make-up"
26
- },
27
- cs: {
28
- directors: "Režie",
29
- writers: "Scénář",
30
- cinematography: "Kamera",
31
- music: "Hudba",
32
- actors: "Hrají",
33
- basedOn: "Předloha",
34
- producers: "Produkce",
35
- filmEditing: "Střih",
36
- costumeDesign: "Kostýmy",
37
- productionDesign: "Scénografie",
38
- casting: "Casting",
39
- sound: "Zvuk",
40
- makeup: "Masky"
41
- },
42
- sk: {
43
- directors: "Réžia",
44
- writers: "Scenár",
45
- cinematography: "Kamera",
46
- music: "Hudba",
47
- actors: "Hrajú",
48
- basedOn: "Predloha",
49
- producers: "Produkcia",
50
- filmEditing: "Strih",
51
- costumeDesign: "Kostýmy",
52
- productionDesign: "Scénografia",
53
- casting: "Casting",
54
- sound: "Zvuk",
55
- makeup: "Masky"
56
- }
57
- };
58
- return (labels[language || "cs"] || labels["cs"])[key];
58
+ return (CREATOR_LABELS[language || "cs"] || CREATOR_LABELS["cs"])[key];
59
59
  };
60
60
  const getMovieTitle = (el) => {
61
61
  return el.querySelector("h1").innerText.split(`(`)[0].trim();
@@ -178,7 +178,7 @@ const getMovieCreators = (el, options) => {
178
178
  return creators;
179
179
  };
180
180
  const getMovieType = (el) => {
181
- return el.querySelector(".film-header-name .type")?.innerText?.replace(/[{()}]/g, "") || "film";
181
+ return parseFilmType(el.querySelector(".film-header-name .type")?.innerText?.replace(/[{()}]/g, "") || "film");
182
182
  };
183
183
  const getMovieVods = (el) => {
184
184
  let vods = [];
@@ -209,8 +209,9 @@ const getMoviePremieres = (el) => {
209
209
  for (const premiereNode of premiereNodes) {
210
210
  const title = premiereNode.querySelector("p + span").attributes.title;
211
211
  if (title) {
212
- const [date, ...company] = title?.split(" ");
213
- premiere.push({
212
+ const [dateRaw, ...company] = title?.split(" ");
213
+ const date = parseDate(dateRaw);
214
+ if (date) premiere.push({
214
215
  country: premiereNode.querySelector(".flag")?.attributes.title || null,
215
216
  format: premiereNode.querySelector("p").textContent.trim()?.split(" od")[0],
216
217
  date,
@@ -1 +1 @@
1
- {"version":3,"file":"movie.helper.mjs","names":[],"sources":["../../src/helpers/movie.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating } from '../dto/global';\nimport {\n CSFDBoxContent,\n CSFDCreatorGroups,\n CSFDCreatorGroupsEnglish,\n CSFDCreatorGroupsSlovak,\n CSFDCreators,\n CSFDGenres,\n CSFDMovieCreator,\n CSFDMovieListItem,\n CSFDPremiere,\n CSFDTitlesOther,\n CSFDVod,\n CSFDVodService,\n MovieJsonLd\n} from '../dto/movie';\nimport { CSFDOptions } from '../types';\nimport { addProtocol, getColor, parseISO8601Duration, parseIdFromUrl } from './global.helper';\n\n/**\n * Maps language-specific movie creator group labels.\n * @param language - The language code (e.g., 'en', 'cs')\n * @param key - The key of the creator group (e.g., 'directors', 'writers')\n * @returns The localized label for the creator group\n */\nexport const getLocalizedCreatorLabel = (\n language: string | undefined,\n key:\n | 'directors'\n | 'writers'\n | 'cinematography'\n | 'music'\n | 'actors'\n | 'basedOn'\n | 'producers'\n | 'filmEditing'\n | 'costumeDesign'\n | 'productionDesign'\n | 'casting'\n | 'sound'\n | 'makeup'\n): CSFDCreatorGroups | CSFDCreatorGroupsEnglish | CSFDCreatorGroupsSlovak => {\n const labels: Record<\n string,\n Record<string, CSFDCreatorGroups | CSFDCreatorGroupsEnglish | CSFDCreatorGroupsSlovak>\n > = {\n en: {\n directors: 'Directed by',\n writers: 'Screenplay',\n cinematography: 'Cinematography',\n music: 'Composer',\n actors: 'Cast',\n basedOn: 'Based on',\n producers: 'Produced by',\n filmEditing: 'Editing',\n costumeDesign: 'Costumes',\n productionDesign: 'Production design',\n casting: 'Casting',\n sound: 'Sound',\n makeup: 'Make-up'\n },\n cs: {\n directors: 'Režie',\n writers: 'Scénář',\n cinematography: 'Kamera',\n music: 'Hudba',\n actors: 'Hrají',\n basedOn: 'Předloha',\n producers: 'Produkce',\n filmEditing: 'Střih',\n costumeDesign: 'Kostýmy',\n productionDesign: 'Scénografie',\n casting: 'Casting',\n sound: 'Zvuk',\n makeup: 'Masky'\n },\n sk: {\n directors: 'Réžia',\n writers: 'Scenár',\n cinematography: 'Kamera',\n music: 'Hudba',\n actors: 'Hrajú',\n basedOn: 'Predloha',\n producers: 'Produkcia',\n filmEditing: 'Strih',\n costumeDesign: 'Kostýmy',\n productionDesign: 'Scénografia',\n casting: 'Casting',\n sound: 'Zvuk',\n makeup: 'Masky'\n }\n };\n\n const lang = language || 'cs'; // Default to Czech\n return (labels[lang] || labels['cs'])[key];\n};\n\nexport const getMovieId = (el: HTMLElement): number => {\n const url = el.querySelector('.tabs .tab-nav-list a').attributes.href;\n return parseIdFromUrl(url);\n};\n\nexport const getMovieTitle = (el: HTMLElement): string => {\n return el.querySelector('h1').innerText.split(`(`)[0].trim();\n};\n\nexport const getMovieGenres = (el: HTMLElement): CSFDGenres[] => {\n const genresRaw = el.querySelector('.genres').textContent;\n return genresRaw.split(' / ') as CSFDGenres[];\n};\n\nexport const getMovieOrigins = (el: HTMLElement): string[] => {\n const originsRaw = el.querySelector('.origin').textContent;\n const origins = originsRaw.split(',')[0];\n return origins.split(' / ');\n};\n\nexport const getMovieColorRating = (bodyClasses: string[]): CSFDColorRating => {\n return getColor(bodyClasses[1]);\n};\n\nexport const getMovieRating = (el: HTMLElement): number => {\n const ratingRaw = el.querySelector('.film-rating-average').textContent;\n const rating = ratingRaw?.replace(/%/g, '').trim();\n const ratingInt = parseInt(rating);\n\n if (Number.isInteger(ratingInt)) {\n return ratingInt;\n } else {\n return null;\n }\n};\n\nexport const getMovieRatingCount = (el: HTMLElement): number => {\n const ratingCountRaw = el.querySelector('.box-rating-container .counter')?.textContent;\n const ratingCount = +ratingCountRaw?.replace(/[(\\s)]/g, '');\n if (Number.isInteger(ratingCount)) {\n return ratingCount;\n } else {\n return null;\n }\n};\n\nexport const getMovieYear = (jsonLd: MovieJsonLd | null): number => {\n if (jsonLd && jsonLd.dateCreated) {\n return +jsonLd.dateCreated;\n }\n return null;\n};\n\nexport const getMovieDuration = (jsonLd: MovieJsonLd | null, el: HTMLElement): number => {\n if (jsonLd && jsonLd.duration) {\n try {\n return parseISO8601Duration(jsonLd.duration);\n } catch (e) {\n // ignore\n }\n }\n\n try {\n const origin = el.querySelector('.origin').innerText;\n const timeString = origin.split(',');\n if (timeString.length > 2) {\n // Get last time elelment\n const timeString2 = timeString.pop().trim();\n // Clean it\n const timeRaw = timeString2.split('(')[0].trim();\n // Split by minutes and hours\n const hoursMinsRaw = timeRaw.split('min')[0];\n const hoursMins = hoursMinsRaw.split('h');\n // Resolve hours + minutes format\n const duration = hoursMins.length > 1 ? +hoursMins[0] * 60 + +hoursMins[1] : +hoursMins[0];\n return duration;\n } else {\n return null;\n }\n } catch (error) {\n return null;\n }\n};\n\nexport const getMovieTitlesOther = (el: HTMLElement): CSFDTitlesOther[] => {\n const namesNode = el.querySelectorAll('.film-names li');\n\n if (!namesNode.length) {\n return [];\n }\n\n const titlesOther = namesNode.map((el) => {\n const country = el.querySelector('img.flag').attributes.alt;\n const title = el.textContent.trim().split('\\n')[0];\n\n if (country && title) {\n return {\n country,\n title\n };\n } else {\n return null;\n }\n });\n\n return titlesOther.filter((x) => x);\n};\n\nexport const getMoviePoster = (el: HTMLElement | null): string => {\n const poster = el.querySelector('.film-posters img');\n // Resolve empty image\n if (poster) {\n if (poster.classNames?.includes('empty-image')) {\n return null;\n } else {\n // Full sized image (not thumb)\n const imageThumb = poster.attributes.src.split('?')[0];\n const image = imageThumb.replace(/\\/w140\\//, '/w1080/');\n return addProtocol(image);\n }\n } else {\n return null;\n }\n};\n\nexport const getMovieRandomPhoto = (el: HTMLElement | null): string => {\n const imageNode = el.querySelector('.gallery-item picture img');\n const image = imageNode?.attributes?.src;\n if (image) {\n return image.replace(/\\/w663\\//, '/w1326/');\n } else {\n return null;\n }\n};\n\nexport const getMovieTrivia = (el: HTMLElement | null): string[] => {\n const triviaNodes = el.querySelectorAll('.article-trivia ul li');\n if (triviaNodes?.length) {\n return triviaNodes.map((node) => node.textContent.trim().replace(/(\\r\\n|\\n|\\r|\\t)/gm, ''));\n } else {\n return null;\n }\n};\n\nexport const getMovieDescriptions = (el: HTMLElement): string[] => {\n return el\n .querySelectorAll('.body--plots .plot-full p, .body--plots .plots .plots-item p')\n .map((movie) => movie.textContent?.trim().replace(/(\\r\\n|\\n|\\r|\\t)/gm, ''));\n};\n\nconst parseMoviePeople = (el: HTMLElement): CSFDMovieCreator[] => {\n const people = el.querySelectorAll('a');\n return (\n people\n // Filter out \"more\" links\n .filter((x) => x.classNames.length === 0)\n .map((person) => {\n return {\n id: parseIdFromUrl(person.attributes.href),\n name: person.innerText.trim(),\n url: `https://www.csfd.cz${person.attributes.href}`\n };\n })\n );\n};\n\n// export const getMovieGroup = (el: HTMLElement, group: CSFDCreatorGroups | CSFDCreatorGroupsEnglish | CSFDCreatorGroupsSlovak): CSFDMovieCreator[] => {\n// const creators = el.querySelectorAll('.creators h4');\n// const element = creators.filter((elem) => elem.textContent.trim().includes(group))[0];\n// if (element?.parentNode) {\n// return parseMoviePeople(element.parentNode as HTMLElement);\n// } else {\n// return [];\n// }\n// };\n\nexport const getMovieCreators = (el: HTMLElement, options?: CSFDOptions): CSFDCreators => {\n const creators: CSFDCreators = {\n directors: [],\n writers: [],\n cinematography: [],\n music: [],\n actors: [],\n basedOn: [],\n producers: [],\n filmEditing: [],\n costumeDesign: [],\n productionDesign: []\n };\n\n const groups = el.querySelectorAll('.creators h4');\n\n const keys = [\n 'directors',\n 'writers',\n 'cinematography',\n 'music',\n 'actors',\n 'basedOn',\n 'producers',\n 'filmEditing',\n 'costumeDesign',\n 'productionDesign'\n ] as const;\n\n const localizedLabels = keys.map((key) => ({\n key,\n label: getLocalizedCreatorLabel(options?.language, key) as string\n }));\n\n for (const group of groups) {\n const text = group.textContent.trim();\n for (const { key, label } of localizedLabels) {\n if (text.includes(label)) {\n if (group.parentNode) {\n creators[key] = parseMoviePeople(group.parentNode as HTMLElement);\n }\n break;\n }\n }\n }\n\n return creators;\n};\n\nexport const getMovieType = (el: HTMLElement): string => {\n const type = el.querySelector('.film-header-name .type');\n return type?.innerText?.replace(/[{()}]/g, '') || 'film';\n};\n\nexport const getMovieVods = (el: HTMLElement | null): CSFDVod[] => {\n let vods: CSFDVod[] = [];\n if (el) {\n const buttonsVod = el.querySelectorAll('.box-buttons-vod .vod-badge a');\n vods = buttonsVod.map((btn) => {\n return {\n title: btn.textContent.trim() as CSFDVodService,\n url: btn.attributes.href\n };\n });\n }\n return vods.length ? vods : [];\n};\n\n// Get box content\nconst getBoxContent = (el: HTMLElement, box: string): HTMLElement => {\n const headers = el.querySelectorAll('section.box .box-header');\n return headers.find((header) => header.querySelector('h3')?.textContent.trim().includes(box))\n ?.parentNode;\n};\n\nexport const getMovieBoxMovies = (\n el: HTMLElement,\n boxName: CSFDBoxContent\n): CSFDMovieListItem[] => {\n const movieListItem: CSFDMovieListItem[] = [];\n const box = getBoxContent(el, boxName);\n const movieTitleNodes = box?.querySelectorAll('.article-header .film-title-name');\n if (movieTitleNodes?.length) {\n for (const item of movieTitleNodes) {\n movieListItem.push({\n id: parseIdFromUrl(item.attributes.href),\n title: item.textContent.trim(),\n url: `https://www.csfd.cz${item.attributes.href}`\n });\n }\n }\n return movieListItem;\n};\n\nexport const getMoviePremieres = (el: HTMLElement): CSFDPremiere[] => {\n const premiereNodes = el.querySelectorAll('.box-premieres li');\n const premiere: CSFDPremiere[] = [];\n for (const premiereNode of premiereNodes) {\n const title = premiereNode.querySelector('p + span').attributes.title;\n\n if (title) {\n const [date, ...company] = title?.split(' ');\n\n premiere.push({\n country: premiereNode.querySelector('.flag')?.attributes.title || null,\n format: premiereNode.querySelector('p').textContent.trim()?.split(' od')[0],\n date,\n company: company.join(' ')\n });\n }\n }\n return premiere;\n};\n\nexport const getMovieTags = (el: HTMLElement): string[] => {\n const tagsRaw = el.querySelectorAll('.box-content a[href*=\"/tag/\"]');\n return tagsRaw.map((tag) => tag.textContent);\n};\n"],"mappings":";;;;;;;;;AA0BA,MAAa,4BACX,UACA,QAc2E;CAC3E,MAAM,SAGF;EACF,IAAI;GACF,WAAW;GACX,SAAS;GACT,gBAAgB;GAChB,OAAO;GACP,QAAQ;GACR,SAAS;GACT,WAAW;GACX,aAAa;GACb,eAAe;GACf,kBAAkB;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AAgC,CACrD,KAAK,QAAQ,IAAI,YAAY"}
1
+ {"version":3,"file":"movie.helper.mjs","names":[],"sources":["../../src/helpers/movie.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating, CSFDFilmTypes } from '../dto/global';\nimport {\n CSFDBoxContent,\n CSFDCreatorGroups,\n CSFDCreatorGroupsEnglish,\n CSFDCreatorGroupsSlovak,\n CSFDCreators,\n CSFDGenres,\n CSFDMovieCreator,\n CSFDMovieListItem,\n CSFDPremiere,\n CSFDTitlesOther,\n CSFDVod,\n CSFDVodService,\n MovieJsonLd\n} from '../dto/movie';\nimport { CSFDOptions } from '../types';\nimport {\n addProtocol,\n getColor,\n parseDate,\n parseFilmType,\n parseISO8601Duration,\n parseIdFromUrl\n} from './global.helper';\n\nconst CREATOR_LABELS: Record<\n string,\n Record<string, CSFDCreatorGroups | CSFDCreatorGroupsEnglish | CSFDCreatorGroupsSlovak>\n> = {\n en: {\n directors: 'Directed by',\n writers: 'Screenplay',\n cinematography: 'Cinematography',\n music: 'Composer',\n actors: 'Cast',\n basedOn: 'Based on',\n producers: 'Produced by',\n filmEditing: 'Editing',\n costumeDesign: 'Costumes',\n productionDesign: 'Production design',\n casting: 'Casting',\n sound: 'Sound',\n makeup: 'Make-up'\n },\n cs: {\n directors: 'Režie',\n writers: 'Scénář',\n cinematography: 'Kamera',\n music: 'Hudba',\n actors: 'Hrají',\n basedOn: 'Předloha',\n producers: 'Produkce',\n filmEditing: 'Střih',\n costumeDesign: 'Kostýmy',\n productionDesign: 'Scénografie',\n casting: 'Casting',\n sound: 'Zvuk',\n makeup: 'Masky'\n },\n sk: {\n directors: 'Réžia',\n writers: 'Scenár',\n cinematography: 'Kamera',\n music: 'Hudba',\n actors: 'Hrajú',\n basedOn: 'Predloha',\n producers: 'Produkcia',\n filmEditing: 'Strih',\n costumeDesign: 'Kostýmy',\n productionDesign: 'Scénografia',\n casting: 'Casting',\n sound: 'Zvuk',\n makeup: 'Masky'\n }\n};\n\n/**\n * Maps language-specific movie creator group labels.\n * @param language - The language code (e.g., 'en', 'cs')\n * @param key - The key of the creator group (e.g., 'directors', 'writers')\n * @returns The localized label for the creator group\n */\nexport const getLocalizedCreatorLabel = (\n language: string | undefined,\n key:\n | 'directors'\n | 'writers'\n | 'cinematography'\n | 'music'\n | 'actors'\n | 'basedOn'\n | 'producers'\n | 'filmEditing'\n | 'costumeDesign'\n | 'productionDesign'\n | 'casting'\n | 'sound'\n | 'makeup'\n): CSFDCreatorGroups | CSFDCreatorGroupsEnglish | CSFDCreatorGroupsSlovak => {\n const lang = language || 'cs'; // Default to Czech\n return (CREATOR_LABELS[lang] || CREATOR_LABELS['cs'])[key];\n};\n\nexport const getMovieId = (el: HTMLElement): number => {\n const url = el.querySelector('.tabs .tab-nav-list a').attributes.href;\n return parseIdFromUrl(url);\n};\n\nexport const getMovieTitle = (el: HTMLElement): string => {\n return el.querySelector('h1').innerText.split(`(`)[0].trim();\n};\n\nexport const getMovieGenres = (el: HTMLElement): CSFDGenres[] => {\n const genresRaw = el.querySelector('.genres').textContent;\n return genresRaw.split(' / ') as CSFDGenres[];\n};\n\nexport const getMovieOrigins = (el: HTMLElement): string[] => {\n const originsRaw = el.querySelector('.origin').textContent;\n const origins = originsRaw.split(',')[0];\n return origins.split(' / ');\n};\n\nexport const getMovieColorRating = (bodyClasses: string[]): CSFDColorRating => {\n return getColor(bodyClasses[1]);\n};\n\nexport const getMovieRating = (el: HTMLElement): number => {\n const ratingRaw = el.querySelector('.film-rating-average').textContent;\n const rating = ratingRaw?.replace(/%/g, '').trim();\n const ratingInt = parseInt(rating);\n\n if (Number.isInteger(ratingInt)) {\n return ratingInt;\n } else {\n return null;\n }\n};\n\nexport const getMovieRatingCount = (el: HTMLElement): number => {\n const ratingCountRaw = el.querySelector('.box-rating-container .counter')?.textContent;\n const ratingCount = +ratingCountRaw?.replace(/[(\\s)]/g, '');\n if (Number.isInteger(ratingCount)) {\n return ratingCount;\n } else {\n return null;\n }\n};\n\nexport const getMovieYear = (jsonLd: MovieJsonLd | null): number => {\n if (jsonLd && jsonLd.dateCreated) {\n return +jsonLd.dateCreated;\n }\n return null;\n};\n\nexport const getMovieDuration = (jsonLd: MovieJsonLd | null, el: HTMLElement): number => {\n if (jsonLd && jsonLd.duration) {\n try {\n return parseISO8601Duration(jsonLd.duration);\n } catch (e) {\n // ignore\n }\n }\n\n try {\n const origin = el.querySelector('.origin').innerText;\n const timeString = origin.split(',');\n if (timeString.length > 2) {\n // Get last time elelment\n const timeString2 = timeString.pop().trim();\n // Clean it\n const timeRaw = timeString2.split('(')[0].trim();\n // Split by minutes and hours\n const hoursMinsRaw = timeRaw.split('min')[0];\n const hoursMins = hoursMinsRaw.split('h');\n // Resolve hours + minutes format\n const duration = hoursMins.length > 1 ? +hoursMins[0] * 60 + +hoursMins[1] : +hoursMins[0];\n return duration;\n } else {\n return null;\n }\n } catch (error) {\n return null;\n }\n};\n\nexport const getMovieTitlesOther = (el: HTMLElement): CSFDTitlesOther[] => {\n const namesNode = el.querySelectorAll('.film-names li');\n\n if (!namesNode.length) {\n return [];\n }\n\n const titlesOther = namesNode.map((el) => {\n const country = el.querySelector('img.flag').attributes.alt;\n const title = el.textContent.trim().split('\\n')[0];\n\n if (country && title) {\n return {\n country,\n title\n };\n } else {\n return null;\n }\n });\n\n return titlesOther.filter((x) => x);\n};\n\nexport const getMoviePoster = (el: HTMLElement | null): string => {\n const poster = el.querySelector('.film-posters img');\n // Resolve empty image\n if (poster) {\n if (poster.classNames?.includes('empty-image')) {\n return null;\n } else {\n // Full sized image (not thumb)\n const imageThumb = poster.attributes.src.split('?')[0];\n const image = imageThumb.replace(/\\/w140\\//, '/w1080/');\n return addProtocol(image);\n }\n } else {\n return null;\n }\n};\n\nexport const getMovieRandomPhoto = (el: HTMLElement | null): string => {\n const imageNode = el.querySelector('.gallery-item picture img');\n const image = imageNode?.attributes?.src;\n if (image) {\n return image.replace(/\\/w663\\//, '/w1326/');\n } else {\n return null;\n }\n};\n\nexport const getMovieTrivia = (el: HTMLElement | null): string[] => {\n const triviaNodes = el.querySelectorAll('.article-trivia ul li');\n if (triviaNodes?.length) {\n return triviaNodes.map((node) => node.textContent.trim().replace(/(\\r\\n|\\n|\\r|\\t)/gm, ''));\n } else {\n return null;\n }\n};\n\nexport const getMovieDescriptions = (el: HTMLElement): string[] => {\n return el\n .querySelectorAll('.body--plots .plot-full p, .body--plots .plots .plots-item p')\n .map((movie) => movie.textContent?.trim().replace(/(\\r\\n|\\n|\\r|\\t)/gm, ''));\n};\n\nconst parseMoviePeople = (el: HTMLElement): CSFDMovieCreator[] => {\n const people = el.querySelectorAll('a');\n return (\n people\n // Filter out \"more\" links\n .filter((x) => x.classNames.length === 0)\n .map((person) => {\n return {\n id: parseIdFromUrl(person.attributes.href),\n name: person.innerText.trim(),\n url: `https://www.csfd.cz${person.attributes.href}`\n };\n })\n );\n};\n\n// export const getMovieGroup = (el: HTMLElement, group: CSFDCreatorGroups | CSFDCreatorGroupsEnglish | CSFDCreatorGroupsSlovak): CSFDMovieCreator[] => {\n// const creators = el.querySelectorAll('.creators h4');\n// const element = creators.filter((elem) => elem.textContent.trim().includes(group))[0];\n// if (element?.parentNode) {\n// return parseMoviePeople(element.parentNode as HTMLElement);\n// } else {\n// return [];\n// }\n// };\n\nexport const getMovieCreators = (el: HTMLElement, options?: CSFDOptions): CSFDCreators => {\n const creators: CSFDCreators = {\n directors: [],\n writers: [],\n cinematography: [],\n music: [],\n actors: [],\n basedOn: [],\n producers: [],\n filmEditing: [],\n costumeDesign: [],\n productionDesign: []\n };\n\n const groups = el.querySelectorAll('.creators h4');\n\n const keys = [\n 'directors',\n 'writers',\n 'cinematography',\n 'music',\n 'actors',\n 'basedOn',\n 'producers',\n 'filmEditing',\n 'costumeDesign',\n 'productionDesign'\n ] as const;\n\n const localizedLabels = keys.map((key) => ({\n key,\n label: getLocalizedCreatorLabel(options?.language, key) as string\n }));\n\n for (const group of groups) {\n const text = group.textContent.trim();\n for (const { key, label } of localizedLabels) {\n if (text.includes(label)) {\n if (group.parentNode) {\n creators[key] = parseMoviePeople(group.parentNode as HTMLElement);\n }\n break;\n }\n }\n }\n\n return creators;\n};\n\nexport const getMovieType = (el: HTMLElement): CSFDFilmTypes => {\n const type = el.querySelector('.film-header-name .type');\n return parseFilmType(type?.innerText?.replace(/[{()}]/g, '') || 'film');\n};\n\nexport const getMovieVods = (el: HTMLElement | null): CSFDVod[] => {\n let vods: CSFDVod[] = [];\n if (el) {\n const buttonsVod = el.querySelectorAll('.box-buttons-vod .vod-badge a');\n vods = buttonsVod.map((btn) => {\n return {\n title: btn.textContent.trim() as CSFDVodService,\n url: btn.attributes.href\n };\n });\n }\n return vods.length ? vods : [];\n};\n\n// Get box content\nconst getBoxContent = (el: HTMLElement, box: string): HTMLElement => {\n const headers = el.querySelectorAll('section.box .box-header');\n return headers.find((header) => header.querySelector('h3')?.textContent.trim().includes(box))\n ?.parentNode;\n};\n\nexport const getMovieBoxMovies = (\n el: HTMLElement,\n boxName: CSFDBoxContent\n): CSFDMovieListItem[] => {\n const movieListItem: CSFDMovieListItem[] = [];\n const box = getBoxContent(el, boxName);\n const movieTitleNodes = box?.querySelectorAll('.article-header .film-title-name');\n if (movieTitleNodes?.length) {\n for (const item of movieTitleNodes) {\n movieListItem.push({\n id: parseIdFromUrl(item.attributes.href),\n title: item.textContent.trim(),\n url: `https://www.csfd.cz${item.attributes.href}`\n });\n }\n }\n return movieListItem;\n};\n\nexport const getMoviePremieres = (el: HTMLElement): CSFDPremiere[] => {\n const premiereNodes = el.querySelectorAll('.box-premieres li');\n const premiere: CSFDPremiere[] = [];\n for (const premiereNode of premiereNodes) {\n const title = premiereNode.querySelector('p + span').attributes.title;\n\n if (title) {\n const [dateRaw, ...company] = title?.split(' ');\n const date = parseDate(dateRaw);\n\n if (date) {\n premiere.push({\n country: premiereNode.querySelector('.flag')?.attributes.title || null,\n format: premiereNode.querySelector('p').textContent.trim()?.split(' od')[0],\n date,\n company: company.join(' ')\n });\n }\n }\n }\n return premiere;\n};\n\nexport const getMovieTags = (el: HTMLElement): string[] => {\n const tagsRaw = el.querySelectorAll('.box-content a[href*=\"/tag/\"]');\n return tagsRaw.map((tag) => tag.textContent);\n};\n"],"mappings":";;;AA2BA,MAAM,iBAGF;CACF,IAAI;EACF,WAAW;EACX,SAAS;EACT,gBAAgB;EAChB,OAAO;EACP,QAAQ;EACR,SAAS;EACT,WAAW;EACX,aAAa;EACb,eAAe;EACf,kBAAkB;EAClB,SAAS;EACT,OAAO;EACP,QAAQ;EACT;CACD,IAAI;EACF,WAAW;EACX,SAAS;EACT,gBAAgB;EAChB,OAAO;EACP,QAAQ;EACR,SAAS;EACT,WAAW;EACX,aAAa;EACb,eAAe;EACf,kBAAkB;EAClB,SAAS;EACT,OAAO;EACP,QAAQ;EACT;CACD,IAAI;EACF,WAAW;EACX,SAAS;EACT,gBAAgB;EAChB,OAAO;EACP,QAAQ;EACR,SAAS;EACT,WAAW;EACX,aAAa;EACb,eAAe;EACf,kBAAkB;EAClB,SAAS;EACT,OAAO;EACP,QAAQ;EACT;CACF;;;;;;;AAQD,MAAa,4BACX,UACA,QAc2E;AAE3E,SAAQ,eADK,YAAY,SACO,eAAe,OAAO;;AAQxD,MAAa,iBAAiB,OAA4B;AACxD,QAAO,GAAG,cAAc,KAAK,CAAC,UAAU,MAAM,IAAI,CAAC,GAAG,MAAM;;AAG9D,MAAa,kBAAkB,OAAkC;AAE/D,QADkB,GAAG,cAAc,UAAU,CAAC,YAC7B,MAAM,MAAM;;AAG/B,MAAa,mBAAmB,OAA8B;AAG5D,QAFmB,GAAG,cAAc,UAAU,CAAC,YACpB,MAAM,IAAI,CAAC,GACvB,MAAM,MAAM;;AAG7B,MAAa,uBAAuB,gBAA2C;AAC7E,QAAO,SAAS,YAAY,GAAG;;AAGjC,MAAa,kBAAkB,OAA4B;CAEzD,MAAM,SADY,GAAG,cAAc,uBAAuB,CAAC,aACjC,QAAQ,MAAM,GAAG,CAAC,MA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,WAAW,CAAC,WAAW;AAEhE,MAAI,OAAO;GACT,MAAM,CAAC,SAAS,GAAG,WAAW,OAAO,MAAM,IAAI;GAC/C,MAAM,OAAO,UAAU,QAAQ;AAE/B,OAAI,KACF,UAAS,KAAK;IACZ,SAAS,aAAa,cAAc,QAAQ,EAAE,WAAW,SAAS;IAClE,QAAQ,aAAa,cAAc,IAAI,CAAC,YAAY,MAAM,EAAE,MAAM,MAAM,CAAC;IACzE;IACA,SAAS,QAAQ,KAAK,IAAI;IAC3B,CAAC;;;AAIR,QAAO;;AAGT,MAAa,gBAAgB,OAA8B;AAEzD,QADgB,GAAG,iBAAiB,kCAAgC,CACrD,KAAK,QAAQ,IAAI,YAAY"}
@@ -2,7 +2,8 @@ const require_global_helper = require('./global.helper.js');
2
2
 
3
3
  //#region src/helpers/search.helper.ts
4
4
  const getSearchType = (el) => {
5
- return el.querySelectorAll(".film-title-info .info")[1]?.innerText?.replace(/[{()}]/g, "")?.trim() || "film";
5
+ const type = el.querySelectorAll(".film-title-info .info")[1];
6
+ return require_global_helper.parseFilmType(type?.innerText?.replace(/[{()}]/g, "")?.trim() || "film");
6
7
  };
7
8
  const getSearchTitle = (el) => {
8
9
  return el.querySelector(".film-title-name").text;
@@ -1 +1 @@
1
- {"version":3,"file":"search.helper.js","names":["parseColor","addProtocol","parseIdFromUrl"],"sources":["../../src/helpers/search.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating, CSFDFilmTypes } from '../dto/global';\nimport { CSFDMovieCreator } from '../dto/movie';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { addProtocol, parseColor, parseIdFromUrl } from './global.helper';\n\ntype Creator = 'Režie:' | 'Hrají:';\n\nexport const getSearchType = (el: HTMLElement): CSFDFilmTypes => {\n const type = el.querySelectorAll('.film-title-info .info')[1];\n return (type?.innerText?.replace(/[{()}]/g, '')?.trim() || 'film') as CSFDFilmTypes;\n};\n\nexport const getSearchTitle = (el: HTMLElement): string => {\n return el.querySelector('.film-title-name').text;\n};\n\nexport const getSearchYear = (el: HTMLElement): number => {\n return +el.querySelectorAll('.film-title-info .info')[0]?.innerText.replace(/[{()}]/g, '');\n};\n\nexport const getSearchUrl = (el: HTMLElement): string => {\n return el.querySelector('.film-title-name').attributes.href;\n};\n\nexport const getSearchColorRating = (el: HTMLElement): CSFDColorRating => {\n return parseColor(\n el.querySelector('.article-header i.icon').classNames.split(' ').pop() as CSFDColors\n );\n};\n\nexport const getSearchPoster = (el: HTMLElement): string => {\n const image = el.querySelector('img').attributes.src;\n return addProtocol(image);\n};\n\nexport const getSearchOrigins = (el: HTMLElement): string[] => {\n const originsRaw = el.querySelector('.article-content p .info')?.text;\n if (!originsRaw) return [];\n const originsAll = originsRaw?.split(', ')?.[0];\n return originsAll?.split('/').map((country) => country.trim());\n};\n\nexport const parseSearchPeople = (el: HTMLElement, type: 'directors' | 'actors'): CSFDMovieCreator[] => {\n let who: Creator;\n if (type === 'directors') who = 'Režie:';\n if (type === 'actors') who = 'Hrají:';\n\n const peopleNode = Array.from(el && el.querySelectorAll('.article-content p')).find((el) =>\n el.textContent.includes(who)\n );\n\n if (peopleNode) {\n const people = Array.from(peopleNode.querySelectorAll('a')) as unknown as HTMLElement[];\n\n return people.map((person) => {\n return {\n id: parseIdFromUrl(person.attributes.href),\n name: person.innerText.trim(),\n url: `https://www.csfd.cz${person.attributes.href}`\n };\n });\n } else {\n return [];\n }\n};\n"],"mappings":";;;AAQA,MAAa,iBAAiB,OAAmC;AAE/D,QADa,GAAG,iBAAiB,yBAAyB,CAAC,IAC7C,WAAW,QAAQ,WAAW,GAAG,EAAE,MAAM,IAAI;;AAG7D,MAAa,kBAAkB,OAA4B;AACzD,QAAO,GAAG,cAAc,mBAAmB,CAAC;;AAG9C,MAAa,iBAAiB,OAA4B;AACxD,QAAO,CAAC,GAAG,iBAAiB,yBAAyB,CAAC,IAAI,UAAU,QAAQ,WAAW,GAAG;;AAG5F,MAAa,gBAAgB,OAA4B;AACvD,QAAO,GAAG,cAAc,mBAAmB,CAAC,WAAW;;AAGzD,MAAa,wBAAwB,OAAqC;AACxE,QAAOA,iCACL,GAAG,cAAc,yBAAyB,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK,CACvE;;AAGH,MAAa,mBAAmB,OAA4B;CAC1D,MAAM,QAAQ,GAAG,cAAc,MAAM,CAAC,WAAW;AACjD,QAAOC,kCAAY,MAAM;;AAG3B,MAAa,oBAAoB,OAA8B;CAC7D,MAAM,aAAa,GAAG,cAAc,2BAA2B,EAAE;AACjE,KAAI,CAAC,WAAY,QAAO,EAAE;AAE1B,SADmB,YAAY,MAAM,KAAK,GAAG,KAC1B,MAAM,IAAI,CAAC,KAAK,YAAY,QAAQ,MAAM,CAAC;;AAGhE,MAAa,qBAAqB,IAAiB,SAAqD;CACtG,IAAI;AACJ,KAAI,SAAS,YAAa,OAAM;AAChC,KAAI,SAAS,SAAU,OAAM;CAE7B,MAAM,aAAa,MAAM,KAAK,MAAM,GAAG,iBAAiB,qBAAqB,CAAC,CAAC,MAAM,OACnF,GAAG,YAAY,SAAS,IAAI,CAC7B;AAED,KAAI,WAGF,QAFe,MAAM,KAAK,WAAW,iBAAiB,IAAI,CAAC,CAE7C,KAAK,WAAW;AAC5B,SAAO;GACL,IAAIC,qCAAe,OAAO,WAAW,KAAK;GAC1C,MAAM,OAAO,UAAU,MAAM;GAC7B,KAAK,sBAAsB,OAAO,WAAW;GAC9C;GACD;KAEF,QAAO,EAAE"}
1
+ {"version":3,"file":"search.helper.js","names":["parseFilmType","parseColor","addProtocol","parseIdFromUrl"],"sources":["../../src/helpers/search.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating, CSFDFilmTypes } from '../dto/global';\nimport { CSFDMovieCreator } from '../dto/movie';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { addProtocol, parseColor, parseFilmType, parseIdFromUrl } from './global.helper';\n\ntype Creator = 'Režie:' | 'Hrají:';\n\nexport const getSearchType = (el: HTMLElement): CSFDFilmTypes => {\n const type = el.querySelectorAll('.film-title-info .info')[1];\n return parseFilmType(type?.innerText?.replace(/[{()}]/g, '')?.trim() || 'film');\n};\n\nexport const getSearchTitle = (el: HTMLElement): string => {\n return el.querySelector('.film-title-name').text;\n};\n\nexport const getSearchYear = (el: HTMLElement): number => {\n return +el.querySelectorAll('.film-title-info .info')[0]?.innerText.replace(/[{()}]/g, '');\n};\n\nexport const getSearchUrl = (el: HTMLElement): string => {\n return el.querySelector('.film-title-name').attributes.href;\n};\n\nexport const getSearchColorRating = (el: HTMLElement): CSFDColorRating => {\n return parseColor(\n el.querySelector('.article-header i.icon').classNames.split(' ').pop() as CSFDColors\n );\n};\n\nexport const getSearchPoster = (el: HTMLElement): string => {\n const image = el.querySelector('img').attributes.src;\n return addProtocol(image);\n};\n\nexport const getSearchOrigins = (el: HTMLElement): string[] => {\n const originsRaw = el.querySelector('.article-content p .info')?.text;\n if (!originsRaw) return [];\n const originsAll = originsRaw?.split(', ')?.[0];\n return originsAll?.split('/').map((country) => country.trim());\n};\n\nexport const parseSearchPeople = (\n el: HTMLElement,\n type: 'directors' | 'actors'\n): CSFDMovieCreator[] => {\n let who: Creator;\n if (type === 'directors') who = 'Režie:';\n if (type === 'actors') who = 'Hrají:';\n\n const peopleNode = Array.from(el && el.querySelectorAll('.article-content p')).find((el) =>\n el.textContent.includes(who)\n );\n\n if (peopleNode) {\n const people = Array.from(peopleNode.querySelectorAll('a')) as unknown as HTMLElement[];\n\n return people.map((person) => {\n return {\n id: parseIdFromUrl(person.attributes.href),\n name: person.innerText.trim(),\n url: `https://www.csfd.cz${person.attributes.href}`\n };\n });\n } else {\n return [];\n }\n};\n"],"mappings":";;;AAQA,MAAa,iBAAiB,OAAmC;CAC/D,MAAM,OAAO,GAAG,iBAAiB,yBAAyB,CAAC;AAC3D,QAAOA,oCAAc,MAAM,WAAW,QAAQ,WAAW,GAAG,EAAE,MAAM,IAAI,OAAO;;AAGjF,MAAa,kBAAkB,OAA4B;AACzD,QAAO,GAAG,cAAc,mBAAmB,CAAC;;AAG9C,MAAa,iBAAiB,OAA4B;AACxD,QAAO,CAAC,GAAG,iBAAiB,yBAAyB,CAAC,IAAI,UAAU,QAAQ,WAAW,GAAG;;AAG5F,MAAa,gBAAgB,OAA4B;AACvD,QAAO,GAAG,cAAc,mBAAmB,CAAC,WAAW;;AAGzD,MAAa,wBAAwB,OAAqC;AACxE,QAAOC,iCACL,GAAG,cAAc,yBAAyB,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK,CACvE;;AAGH,MAAa,mBAAmB,OAA4B;CAC1D,MAAM,QAAQ,GAAG,cAAc,MAAM,CAAC,WAAW;AACjD,QAAOC,kCAAY,MAAM;;AAG3B,MAAa,oBAAoB,OAA8B;CAC7D,MAAM,aAAa,GAAG,cAAc,2BAA2B,EAAE;AACjE,KAAI,CAAC,WAAY,QAAO,EAAE;AAE1B,SADmB,YAAY,MAAM,KAAK,GAAG,KAC1B,MAAM,IAAI,CAAC,KAAK,YAAY,QAAQ,MAAM,CAAC;;AAGhE,MAAa,qBACX,IACA,SACuB;CACvB,IAAI;AACJ,KAAI,SAAS,YAAa,OAAM;AAChC,KAAI,SAAS,SAAU,OAAM;CAE7B,MAAM,aAAa,MAAM,KAAK,MAAM,GAAG,iBAAiB,qBAAqB,CAAC,CAAC,MAAM,OACnF,GAAG,YAAY,SAAS,IAAI,CAC7B;AAED,KAAI,WAGF,QAFe,MAAM,KAAK,WAAW,iBAAiB,IAAI,CAAC,CAE7C,KAAK,WAAW;AAC5B,SAAO;GACL,IAAIC,qCAAe,OAAO,WAAW,KAAK;GAC1C,MAAM,OAAO,UAAU,MAAM;GAC7B,KAAK,sBAAsB,OAAO,WAAW;GAC9C;GACD;KAEF,QAAO,EAAE"}
@@ -1,8 +1,9 @@
1
- import { addProtocol, parseColor, parseIdFromUrl } from "./global.helper.mjs";
1
+ import { addProtocol, parseColor, parseFilmType, parseIdFromUrl } from "./global.helper.mjs";
2
2
 
3
3
  //#region src/helpers/search.helper.ts
4
4
  const getSearchType = (el) => {
5
- return el.querySelectorAll(".film-title-info .info")[1]?.innerText?.replace(/[{()}]/g, "")?.trim() || "film";
5
+ const type = el.querySelectorAll(".film-title-info .info")[1];
6
+ return parseFilmType(type?.innerText?.replace(/[{()}]/g, "")?.trim() || "film");
6
7
  };
7
8
  const getSearchTitle = (el) => {
8
9
  return el.querySelector(".film-title-name").text;
@@ -1 +1 @@
1
- {"version":3,"file":"search.helper.mjs","names":[],"sources":["../../src/helpers/search.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating, CSFDFilmTypes } from '../dto/global';\nimport { CSFDMovieCreator } from '../dto/movie';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { addProtocol, parseColor, parseIdFromUrl } from './global.helper';\n\ntype Creator = 'Režie:' | 'Hrají:';\n\nexport const getSearchType = (el: HTMLElement): CSFDFilmTypes => {\n const type = el.querySelectorAll('.film-title-info .info')[1];\n return (type?.innerText?.replace(/[{()}]/g, '')?.trim() || 'film') as CSFDFilmTypes;\n};\n\nexport const getSearchTitle = (el: HTMLElement): string => {\n return el.querySelector('.film-title-name').text;\n};\n\nexport const getSearchYear = (el: HTMLElement): number => {\n return +el.querySelectorAll('.film-title-info .info')[0]?.innerText.replace(/[{()}]/g, '');\n};\n\nexport const getSearchUrl = (el: HTMLElement): string => {\n return el.querySelector('.film-title-name').attributes.href;\n};\n\nexport const getSearchColorRating = (el: HTMLElement): CSFDColorRating => {\n return parseColor(\n el.querySelector('.article-header i.icon').classNames.split(' ').pop() as CSFDColors\n );\n};\n\nexport const getSearchPoster = (el: HTMLElement): string => {\n const image = el.querySelector('img').attributes.src;\n return addProtocol(image);\n};\n\nexport const getSearchOrigins = (el: HTMLElement): string[] => {\n const originsRaw = el.querySelector('.article-content p .info')?.text;\n if (!originsRaw) return [];\n const originsAll = originsRaw?.split(', ')?.[0];\n return originsAll?.split('/').map((country) => country.trim());\n};\n\nexport const parseSearchPeople = (el: HTMLElement, type: 'directors' | 'actors'): CSFDMovieCreator[] => {\n let who: Creator;\n if (type === 'directors') who = 'Režie:';\n if (type === 'actors') who = 'Hrají:';\n\n const peopleNode = Array.from(el && el.querySelectorAll('.article-content p')).find((el) =>\n el.textContent.includes(who)\n );\n\n if (peopleNode) {\n const people = Array.from(peopleNode.querySelectorAll('a')) as unknown as HTMLElement[];\n\n return people.map((person) => {\n return {\n id: parseIdFromUrl(person.attributes.href),\n name: person.innerText.trim(),\n url: `https://www.csfd.cz${person.attributes.href}`\n };\n });\n } else {\n return [];\n }\n};\n"],"mappings":";;;AAQA,MAAa,iBAAiB,OAAmC;AAE/D,QADa,GAAG,iBAAiB,yBAAyB,CAAC,IAC7C,WAAW,QAAQ,WAAW,GAAG,EAAE,MAAM,IAAI;;AAG7D,MAAa,kBAAkB,OAA4B;AACzD,QAAO,GAAG,cAAc,mBAAmB,CAAC;;AAG9C,MAAa,iBAAiB,OAA4B;AACxD,QAAO,CAAC,GAAG,iBAAiB,yBAAyB,CAAC,IAAI,UAAU,QAAQ,WAAW,GAAG;;AAG5F,MAAa,gBAAgB,OAA4B;AACvD,QAAO,GAAG,cAAc,mBAAmB,CAAC,WAAW;;AAGzD,MAAa,wBAAwB,OAAqC;AACxE,QAAO,WACL,GAAG,cAAc,yBAAyB,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK,CACvE;;AAGH,MAAa,mBAAmB,OAA4B;CAC1D,MAAM,QAAQ,GAAG,cAAc,MAAM,CAAC,WAAW;AACjD,QAAO,YAAY,MAAM;;AAG3B,MAAa,oBAAoB,OAA8B;CAC7D,MAAM,aAAa,GAAG,cAAc,2BAA2B,EAAE;AACjE,KAAI,CAAC,WAAY,QAAO,EAAE;AAE1B,SADmB,YAAY,MAAM,KAAK,GAAG,KAC1B,MAAM,IAAI,CAAC,KAAK,YAAY,QAAQ,MAAM,CAAC;;AAGhE,MAAa,qBAAqB,IAAiB,SAAqD;CACtG,IAAI;AACJ,KAAI,SAAS,YAAa,OAAM;AAChC,KAAI,SAAS,SAAU,OAAM;CAE7B,MAAM,aAAa,MAAM,KAAK,MAAM,GAAG,iBAAiB,qBAAqB,CAAC,CAAC,MAAM,OACnF,GAAG,YAAY,SAAS,IAAI,CAC7B;AAED,KAAI,WAGF,QAFe,MAAM,KAAK,WAAW,iBAAiB,IAAI,CAAC,CAE7C,KAAK,WAAW;AAC5B,SAAO;GACL,IAAI,eAAe,OAAO,WAAW,KAAK;GAC1C,MAAM,OAAO,UAAU,MAAM;GAC7B,KAAK,sBAAsB,OAAO,WAAW;GAC9C;GACD;KAEF,QAAO,EAAE"}
1
+ {"version":3,"file":"search.helper.mjs","names":[],"sources":["../../src/helpers/search.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating, CSFDFilmTypes } from '../dto/global';\nimport { CSFDMovieCreator } from '../dto/movie';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { addProtocol, parseColor, parseFilmType, parseIdFromUrl } from './global.helper';\n\ntype Creator = 'Režie:' | 'Hrají:';\n\nexport const getSearchType = (el: HTMLElement): CSFDFilmTypes => {\n const type = el.querySelectorAll('.film-title-info .info')[1];\n return parseFilmType(type?.innerText?.replace(/[{()}]/g, '')?.trim() || 'film');\n};\n\nexport const getSearchTitle = (el: HTMLElement): string => {\n return el.querySelector('.film-title-name').text;\n};\n\nexport const getSearchYear = (el: HTMLElement): number => {\n return +el.querySelectorAll('.film-title-info .info')[0]?.innerText.replace(/[{()}]/g, '');\n};\n\nexport const getSearchUrl = (el: HTMLElement): string => {\n return el.querySelector('.film-title-name').attributes.href;\n};\n\nexport const getSearchColorRating = (el: HTMLElement): CSFDColorRating => {\n return parseColor(\n el.querySelector('.article-header i.icon').classNames.split(' ').pop() as CSFDColors\n );\n};\n\nexport const getSearchPoster = (el: HTMLElement): string => {\n const image = el.querySelector('img').attributes.src;\n return addProtocol(image);\n};\n\nexport const getSearchOrigins = (el: HTMLElement): string[] => {\n const originsRaw = el.querySelector('.article-content p .info')?.text;\n if (!originsRaw) return [];\n const originsAll = originsRaw?.split(', ')?.[0];\n return originsAll?.split('/').map((country) => country.trim());\n};\n\nexport const parseSearchPeople = (\n el: HTMLElement,\n type: 'directors' | 'actors'\n): CSFDMovieCreator[] => {\n let who: Creator;\n if (type === 'directors') who = 'Režie:';\n if (type === 'actors') who = 'Hrají:';\n\n const peopleNode = Array.from(el && el.querySelectorAll('.article-content p')).find((el) =>\n el.textContent.includes(who)\n );\n\n if (peopleNode) {\n const people = Array.from(peopleNode.querySelectorAll('a')) as unknown as HTMLElement[];\n\n return people.map((person) => {\n return {\n id: parseIdFromUrl(person.attributes.href),\n name: person.innerText.trim(),\n url: `https://www.csfd.cz${person.attributes.href}`\n };\n });\n } else {\n return [];\n }\n};\n"],"mappings":";;;AAQA,MAAa,iBAAiB,OAAmC;CAC/D,MAAM,OAAO,GAAG,iBAAiB,yBAAyB,CAAC;AAC3D,QAAO,cAAc,MAAM,WAAW,QAAQ,WAAW,GAAG,EAAE,MAAM,IAAI,OAAO;;AAGjF,MAAa,kBAAkB,OAA4B;AACzD,QAAO,GAAG,cAAc,mBAAmB,CAAC;;AAG9C,MAAa,iBAAiB,OAA4B;AACxD,QAAO,CAAC,GAAG,iBAAiB,yBAAyB,CAAC,IAAI,UAAU,QAAQ,WAAW,GAAG;;AAG5F,MAAa,gBAAgB,OAA4B;AACvD,QAAO,GAAG,cAAc,mBAAmB,CAAC,WAAW;;AAGzD,MAAa,wBAAwB,OAAqC;AACxE,QAAO,WACL,GAAG,cAAc,yBAAyB,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK,CACvE;;AAGH,MAAa,mBAAmB,OAA4B;CAC1D,MAAM,QAAQ,GAAG,cAAc,MAAM,CAAC,WAAW;AACjD,QAAO,YAAY,MAAM;;AAG3B,MAAa,oBAAoB,OAA8B;CAC7D,MAAM,aAAa,GAAG,cAAc,2BAA2B,EAAE;AACjE,KAAI,CAAC,WAAY,QAAO,EAAE;AAE1B,SADmB,YAAY,MAAM,KAAK,GAAG,KAC1B,MAAM,IAAI,CAAC,KAAK,YAAY,QAAQ,MAAM,CAAC;;AAGhE,MAAa,qBACX,IACA,SACuB;CACvB,IAAI;AACJ,KAAI,SAAS,YAAa,OAAM;AAChC,KAAI,SAAS,SAAU,OAAM;CAE7B,MAAM,aAAa,MAAM,KAAK,MAAM,GAAG,iBAAiB,qBAAqB,CAAC,CAAC,MAAM,OACnF,GAAG,YAAY,SAAS,IAAI,CAC7B;AAED,KAAI,WAGF,QAFe,MAAM,KAAK,WAAW,iBAAiB,IAAI,CAAC,CAE7C,KAAK,WAAW;AAC5B,SAAO;GACL,IAAI,eAAe,OAAO,WAAW,KAAK;GAC1C,MAAM,OAAO,UAAU,MAAM;GAC7B,KAAK,sBAAsB,OAAO,WAAW;GAC9C;GACD;KAEF,QAAO,EAAE"}
@@ -11,7 +11,7 @@ const getUserRating = (el) => {
11
11
  };
12
12
  const getUserRatingType = (el) => {
13
13
  const typeText = el.querySelectorAll("td.name .film-title-info .info");
14
- return typeText.length > 1 ? typeText[1].text : "film";
14
+ return require_global_helper.parseFilmType(typeText.length > 1 ? typeText[1].text : "film");
15
15
  };
16
16
  const getUserRatingTitle = (el) => {
17
17
  return el.querySelector("td.name .film-title-name").text;
@@ -1 +1 @@
1
- {"version":3,"file":"user-ratings.helper.js","names":["parseIdFromUrl","parseColor"],"sources":["../../src/helpers/user-ratings.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { parseColor, parseIdFromUrl } from './global.helper';\n\nexport const getUserRatingId = (el: HTMLElement): number => {\n const url = el.querySelector('td.name .film-title-name').attributes.href;\n return parseIdFromUrl(url);\n};\n\nexport const getUserRating = (el: HTMLElement): CSFDStars => {\n const ratingText = el.querySelector('td.star-rating-only .stars').classNames.split(' ').pop();\n\n const rating = ratingText.includes('stars-') ? +ratingText.split('-').pop() : 0;\n return rating as CSFDStars;\n};\n\nexport const getUserRatingType = (el: HTMLElement): CSFDFilmTypes => {\n const typeText = el.querySelectorAll('td.name .film-title-info .info');\n\n return (typeText.length > 1 ? typeText[1].text : 'film') as CSFDFilmTypes;\n};\n\nexport const getUserRatingTitle = (el: HTMLElement): string => {\n return el.querySelector('td.name .film-title-name').text;\n};\n\nexport const getUserRatingYear = (el: HTMLElement): number => {\n return +el.querySelectorAll('td.name .film-title-info .info')[0]?.text || null;\n};\n\nexport const getUserRatingColorRating = (el: HTMLElement): CSFDColorRating => {\n const color = parseColor(\n el.querySelector('td.name .icon').classNames.split(' ').pop() as CSFDColors\n );\n return color;\n};\n\nexport const getUserRatingDate = (el: HTMLElement): string => {\n return el.querySelector('td.date-only').text.trim();\n};\n\nexport const getUserRatingUrl = (el: HTMLElement): string => {\n const url = el.querySelector('td.name .film-title-name').attributes.href;\n return `https://www.csfd.cz${url}`;\n};\n"],"mappings":";;;AAKA,MAAa,mBAAmB,OAA4B;CAC1D,MAAM,MAAM,GAAG,cAAc,2BAA2B,CAAC,WAAW;AACpE,QAAOA,qCAAe,IAAI;;AAG5B,MAAa,iBAAiB,OAA+B;CAC3D,MAAM,aAAa,GAAG,cAAc,6BAA6B,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK;AAG7F,QADe,WAAW,SAAS,SAAS,GAAG,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK,GAAG;;AAIhF,MAAa,qBAAqB,OAAmC;CACnE,MAAM,WAAW,GAAG,iBAAiB,iCAAiC;AAEtE,QAAQ,SAAS,SAAS,IAAI,SAAS,GAAG,OAAO;;AAGnD,MAAa,sBAAsB,OAA4B;AAC7D,QAAO,GAAG,cAAc,2BAA2B,CAAC;;AAGtD,MAAa,qBAAqB,OAA4B;AAC5D,QAAO,CAAC,GAAG,iBAAiB,iCAAiC,CAAC,IAAI,QAAQ;;AAG5E,MAAa,4BAA4B,OAAqC;AAI5E,QAHcC,iCACZ,GAAG,cAAc,gBAAgB,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK,CAC9D;;AAIH,MAAa,qBAAqB,OAA4B;AAC5D,QAAO,GAAG,cAAc,eAAe,CAAC,KAAK,MAAM;;AAGrD,MAAa,oBAAoB,OAA4B;AAE3D,QAAO,sBADK,GAAG,cAAc,2BAA2B,CAAC,WAAW"}
1
+ {"version":3,"file":"user-ratings.helper.js","names":["parseIdFromUrl","parseFilmType","parseColor"],"sources":["../../src/helpers/user-ratings.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { parseColor, parseFilmType, parseIdFromUrl } from './global.helper';\n\nexport const getUserRatingId = (el: HTMLElement): number => {\n const url = el.querySelector('td.name .film-title-name').attributes.href;\n return parseIdFromUrl(url);\n};\n\nexport const getUserRating = (el: HTMLElement): CSFDStars => {\n const ratingText = el.querySelector('td.star-rating-only .stars').classNames.split(' ').pop();\n\n const rating = ratingText.includes('stars-') ? +ratingText.split('-').pop() : 0;\n return rating as CSFDStars;\n};\n\nexport const getUserRatingType = (el: HTMLElement): CSFDFilmTypes => {\n const typeText = el.querySelectorAll('td.name .film-title-info .info');\n\n return parseFilmType(typeText.length > 1 ? typeText[1].text : 'film');\n};\n\nexport const getUserRatingTitle = (el: HTMLElement): string => {\n return el.querySelector('td.name .film-title-name').text;\n};\n\nexport const getUserRatingYear = (el: HTMLElement): number => {\n return +el.querySelectorAll('td.name .film-title-info .info')[0]?.text || null;\n};\n\nexport const getUserRatingColorRating = (el: HTMLElement): CSFDColorRating => {\n const color = parseColor(\n el.querySelector('td.name .icon').classNames.split(' ').pop() as CSFDColors\n );\n return color;\n};\n\nexport const getUserRatingDate = (el: HTMLElement): string => {\n return el.querySelector('td.date-only').text.trim();\n};\n\nexport const getUserRatingUrl = (el: HTMLElement): string => {\n const url = el.querySelector('td.name .film-title-name').attributes.href;\n return `https://www.csfd.cz${url}`;\n};\n"],"mappings":";;;AAKA,MAAa,mBAAmB,OAA4B;CAC1D,MAAM,MAAM,GAAG,cAAc,2BAA2B,CAAC,WAAW;AACpE,QAAOA,qCAAe,IAAI;;AAG5B,MAAa,iBAAiB,OAA+B;CAC3D,MAAM,aAAa,GAAG,cAAc,6BAA6B,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK;AAG7F,QADe,WAAW,SAAS,SAAS,GAAG,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK,GAAG;;AAIhF,MAAa,qBAAqB,OAAmC;CACnE,MAAM,WAAW,GAAG,iBAAiB,iCAAiC;AAEtE,QAAOC,oCAAc,SAAS,SAAS,IAAI,SAAS,GAAG,OAAO,OAAO;;AAGvE,MAAa,sBAAsB,OAA4B;AAC7D,QAAO,GAAG,cAAc,2BAA2B,CAAC;;AAGtD,MAAa,qBAAqB,OAA4B;AAC5D,QAAO,CAAC,GAAG,iBAAiB,iCAAiC,CAAC,IAAI,QAAQ;;AAG5E,MAAa,4BAA4B,OAAqC;AAI5E,QAHcC,iCACZ,GAAG,cAAc,gBAAgB,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK,CAC9D;;AAIH,MAAa,qBAAqB,OAA4B;AAC5D,QAAO,GAAG,cAAc,eAAe,CAAC,KAAK,MAAM;;AAGrD,MAAa,oBAAoB,OAA4B;AAE3D,QAAO,sBADK,GAAG,cAAc,2BAA2B,CAAC,WAAW"}
@@ -1,4 +1,4 @@
1
- import { parseColor, parseIdFromUrl } from "./global.helper.mjs";
1
+ import { parseColor, parseFilmType, parseIdFromUrl } from "./global.helper.mjs";
2
2
 
3
3
  //#region src/helpers/user-ratings.helper.ts
4
4
  const getUserRatingId = (el) => {
@@ -11,7 +11,7 @@ const getUserRating = (el) => {
11
11
  };
12
12
  const getUserRatingType = (el) => {
13
13
  const typeText = el.querySelectorAll("td.name .film-title-info .info");
14
- return typeText.length > 1 ? typeText[1].text : "film";
14
+ return parseFilmType(typeText.length > 1 ? typeText[1].text : "film");
15
15
  };
16
16
  const getUserRatingTitle = (el) => {
17
17
  return el.querySelector("td.name .film-title-name").text;
@@ -1 +1 @@
1
- {"version":3,"file":"user-ratings.helper.mjs","names":[],"sources":["../../src/helpers/user-ratings.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { parseColor, parseIdFromUrl } from './global.helper';\n\nexport const getUserRatingId = (el: HTMLElement): number => {\n const url = el.querySelector('td.name .film-title-name').attributes.href;\n return parseIdFromUrl(url);\n};\n\nexport const getUserRating = (el: HTMLElement): CSFDStars => {\n const ratingText = el.querySelector('td.star-rating-only .stars').classNames.split(' ').pop();\n\n const rating = ratingText.includes('stars-') ? +ratingText.split('-').pop() : 0;\n return rating as CSFDStars;\n};\n\nexport const getUserRatingType = (el: HTMLElement): CSFDFilmTypes => {\n const typeText = el.querySelectorAll('td.name .film-title-info .info');\n\n return (typeText.length > 1 ? typeText[1].text : 'film') as CSFDFilmTypes;\n};\n\nexport const getUserRatingTitle = (el: HTMLElement): string => {\n return el.querySelector('td.name .film-title-name').text;\n};\n\nexport const getUserRatingYear = (el: HTMLElement): number => {\n return +el.querySelectorAll('td.name .film-title-info .info')[0]?.text || null;\n};\n\nexport const getUserRatingColorRating = (el: HTMLElement): CSFDColorRating => {\n const color = parseColor(\n el.querySelector('td.name .icon').classNames.split(' ').pop() as CSFDColors\n );\n return color;\n};\n\nexport const getUserRatingDate = (el: HTMLElement): string => {\n return el.querySelector('td.date-only').text.trim();\n};\n\nexport const getUserRatingUrl = (el: HTMLElement): string => {\n const url = el.querySelector('td.name .film-title-name').attributes.href;\n return `https://www.csfd.cz${url}`;\n};\n"],"mappings":";;;AAKA,MAAa,mBAAmB,OAA4B;CAC1D,MAAM,MAAM,GAAG,cAAc,2BAA2B,CAAC,WAAW;AACpE,QAAO,eAAe,IAAI;;AAG5B,MAAa,iBAAiB,OAA+B;CAC3D,MAAM,aAAa,GAAG,cAAc,6BAA6B,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK;AAG7F,QADe,WAAW,SAAS,SAAS,GAAG,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK,GAAG;;AAIhF,MAAa,qBAAqB,OAAmC;CACnE,MAAM,WAAW,GAAG,iBAAiB,iCAAiC;AAEtE,QAAQ,SAAS,SAAS,IAAI,SAAS,GAAG,OAAO;;AAGnD,MAAa,sBAAsB,OAA4B;AAC7D,QAAO,GAAG,cAAc,2BAA2B,CAAC;;AAGtD,MAAa,qBAAqB,OAA4B;AAC5D,QAAO,CAAC,GAAG,iBAAiB,iCAAiC,CAAC,IAAI,QAAQ;;AAG5E,MAAa,4BAA4B,OAAqC;AAI5E,QAHc,WACZ,GAAG,cAAc,gBAAgB,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK,CAC9D;;AAIH,MAAa,qBAAqB,OAA4B;AAC5D,QAAO,GAAG,cAAc,eAAe,CAAC,KAAK,MAAM;;AAGrD,MAAa,oBAAoB,OAA4B;AAE3D,QAAO,sBADK,GAAG,cAAc,2BAA2B,CAAC,WAAW"}
1
+ {"version":3,"file":"user-ratings.helper.mjs","names":[],"sources":["../../src/helpers/user-ratings.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { parseColor, parseFilmType, parseIdFromUrl } from './global.helper';\n\nexport const getUserRatingId = (el: HTMLElement): number => {\n const url = el.querySelector('td.name .film-title-name').attributes.href;\n return parseIdFromUrl(url);\n};\n\nexport const getUserRating = (el: HTMLElement): CSFDStars => {\n const ratingText = el.querySelector('td.star-rating-only .stars').classNames.split(' ').pop();\n\n const rating = ratingText.includes('stars-') ? +ratingText.split('-').pop() : 0;\n return rating as CSFDStars;\n};\n\nexport const getUserRatingType = (el: HTMLElement): CSFDFilmTypes => {\n const typeText = el.querySelectorAll('td.name .film-title-info .info');\n\n return parseFilmType(typeText.length > 1 ? typeText[1].text : 'film');\n};\n\nexport const getUserRatingTitle = (el: HTMLElement): string => {\n return el.querySelector('td.name .film-title-name').text;\n};\n\nexport const getUserRatingYear = (el: HTMLElement): number => {\n return +el.querySelectorAll('td.name .film-title-info .info')[0]?.text || null;\n};\n\nexport const getUserRatingColorRating = (el: HTMLElement): CSFDColorRating => {\n const color = parseColor(\n el.querySelector('td.name .icon').classNames.split(' ').pop() as CSFDColors\n );\n return color;\n};\n\nexport const getUserRatingDate = (el: HTMLElement): string => {\n return el.querySelector('td.date-only').text.trim();\n};\n\nexport const getUserRatingUrl = (el: HTMLElement): string => {\n const url = el.querySelector('td.name .film-title-name').attributes.href;\n return `https://www.csfd.cz${url}`;\n};\n"],"mappings":";;;AAKA,MAAa,mBAAmB,OAA4B;CAC1D,MAAM,MAAM,GAAG,cAAc,2BAA2B,CAAC,WAAW;AACpE,QAAO,eAAe,IAAI;;AAG5B,MAAa,iBAAiB,OAA+B;CAC3D,MAAM,aAAa,GAAG,cAAc,6BAA6B,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK;AAG7F,QADe,WAAW,SAAS,SAAS,GAAG,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK,GAAG;;AAIhF,MAAa,qBAAqB,OAAmC;CACnE,MAAM,WAAW,GAAG,iBAAiB,iCAAiC;AAEtE,QAAO,cAAc,SAAS,SAAS,IAAI,SAAS,GAAG,OAAO,OAAO;;AAGvE,MAAa,sBAAsB,OAA4B;AAC7D,QAAO,GAAG,cAAc,2BAA2B,CAAC;;AAGtD,MAAa,qBAAqB,OAA4B;AAC5D,QAAO,CAAC,GAAG,iBAAiB,iCAAiC,CAAC,IAAI,QAAQ;;AAG5E,MAAa,4BAA4B,OAAqC;AAI5E,QAHc,WACZ,GAAG,cAAc,gBAAgB,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK,CAC9D;;AAIH,MAAa,qBAAqB,OAA4B;AAC5D,QAAO,GAAG,cAAc,eAAe,CAAC,KAAK,MAAM;;AAGrD,MAAa,oBAAoB,OAA4B;AAE3D,QAAO,sBADK,GAAG,cAAc,2BAA2B,CAAC,WAAW"}
@@ -11,7 +11,7 @@ const getUserReviewRating = (el) => {
11
11
  };
12
12
  const getUserReviewType = (el) => {
13
13
  const typeText = el.querySelectorAll(".film-title-info .info");
14
- return typeText.length > 1 ? typeText[1].text.slice(1, -1) : "film";
14
+ return require_global_helper.parseFilmType(typeText.length > 1 ? typeText[1].text.slice(1, -1) : "film");
15
15
  };
16
16
  const getUserReviewTitle = (el) => {
17
17
  return el.querySelector(".film-title-name").text;
@@ -24,7 +24,7 @@ const getUserReviewColorRating = (el) => {
24
24
  return require_global_helper.parseColor(el.querySelector(".film-title-inline i.icon")?.classNames.split(" ").pop());
25
25
  };
26
26
  const getUserReviewDate = (el) => {
27
- return el.querySelector(".article-header-date-content .info time").text.trim();
27
+ return require_global_helper.parseDate(el.querySelector(".article-header-date-content .info time").text.trim());
28
28
  };
29
29
  const getUserReviewUrl = (el) => {
30
30
  return `https://www.csfd.cz${el.querySelector(".film-title-name").attributes.href}`;
@@ -1 +1 @@
1
- {"version":3,"file":"user-reviews.helper.js","names":["parseIdFromUrl","parseColor"],"sources":["../../src/helpers/user-reviews.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { parseColor, parseIdFromUrl } from './global.helper';\n\nexport const getUserReviewId = (el: HTMLElement): number => {\n const url = el.querySelector('.film-title-name').attributes.href;\n return parseIdFromUrl(url);\n};\n\nexport const getUserReviewRating = (el: HTMLElement): CSFDStars => {\n const ratingText = el.querySelector('.star-rating .stars').classNames.split(' ').pop();\n\n const rating = ratingText.includes('stars-') ? +ratingText.split('-').pop() : 0;\n return rating as CSFDStars;\n};\n\nexport const getUserReviewType = (el: HTMLElement): CSFDFilmTypes => {\n // Type can be in the second .info span (e.g., \"(seriál)\") // TODO need more tests\n const typeText = el.querySelectorAll('.film-title-info .info');\n\n return (typeText.length > 1 ? typeText[1].text.slice(1, -1) : 'film') as CSFDFilmTypes;\n};\n\nexport const getUserReviewTitle = (el: HTMLElement): string => {\n return el.querySelector('.film-title-name').text;\n};\n\nexport const getUserReviewYear = (el: HTMLElement): number => {\n const infoSpan = el.querySelector('.film-title-info .info');\n return infoSpan ? +infoSpan.text.replace(/[()]/g, '') : null;\n};\n\nexport const getUserReviewColorRating = (el: HTMLElement): CSFDColorRating => {\n const icon = el.querySelector('.film-title-inline i.icon');\n const color = parseColor(icon?.classNames.split(' ').pop() as CSFDColors);\n return color;\n};\n\nexport const getUserReviewDate = (el: HTMLElement): string => {\n return el.querySelector('.article-header-date-content .info time').text.trim();\n};\n\nexport const getUserReviewUrl = (el: HTMLElement): string => {\n const url = el.querySelector('.film-title-name').attributes.href;\n return `https://www.csfd.cz${url}`;\n};\n\nexport const getUserReviewText = (el: HTMLElement): string => {\n return el.querySelector('.comment').text.trim();\n};\n\nexport const getUserReviewPoster = (el: HTMLElement): string => {\n const img = el.querySelector('.article-img img');\n const srcset = img?.attributes.srcset;\n\n if (srcset) {\n // Extract 3x version from srcset (e.g., \"url 1x, url 2x, url 3x\")\n const srcsetParts = srcset.split(',').map((s) => s.trim());\n const poster3x = srcsetParts.find((s) => s.endsWith('3x'));\n if (poster3x) {\n const url = poster3x.replace(/\\s+3x$/, '').trim();\n return `https:${url}`;\n }\n }\n\n // Fallback to src if srcset not available\n const src = img?.attributes.src;\n return src ? `https:${src}` : null;\n};\n"],"mappings":";;;AAKA,MAAa,mBAAmB,OAA4B;CAC1D,MAAM,MAAM,GAAG,cAAc,mBAAmB,CAAC,WAAW;AAC5D,QAAOA,qCAAe,IAAI;;AAG5B,MAAa,uBAAuB,OAA+B;CACjE,MAAM,aAAa,GAAG,cAAc,sBAAsB,CAAC,WAAW,MAAM,IAAI,CAAC,K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../src/helpers/user-reviews.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { parseColor, parseDate, parseFilmType, parseIdFromUrl } from './global.helper';\n\nexport const getUserReviewId = (el: HTMLElement): number => {\n const url = el.querySelector('.film-title-name').attributes.href;\n return parseIdFromUrl(url);\n};\n\nexport const getUserReviewRating = (el: HTMLElement): CSFDStars => {\n const ratingText = el.querySelector('.star-rating .stars').classNames.split(' ').pop();\n\n const rating = ratingText.includes('stars-') ? +ratingText.split('-').pop() : 0;\n return rating as CSFDStars;\n};\n\nexport const getUserReviewType = (el: HTMLElement): CSFDFilmTypes => {\n // Type can be in the second .info span (e.g., \"(seriál)\") // TODO need more tests\n const typeText = el.querySelectorAll('.film-title-info .info');\n\n return parseFilmType(typeText.length > 1 ? typeText[1].text.slice(1, -1) : 'film');\n};\n\nexport const getUserReviewTitle = (el: HTMLElement): string => {\n return el.querySelector('.film-title-name').text;\n};\n\nexport const getUserReviewYear = (el: HTMLElement): number => {\n const infoSpan = el.querySelector('.film-title-info .info');\n return infoSpan ? +infoSpan.text.replace(/[()]/g, '') : null;\n};\n\nexport const getUserReviewColorRating = (el: HTMLElement): CSFDColorRating => {\n const icon = el.querySelector('.film-title-inline i.icon');\n const color = parseColor(icon?.classNames.split(' ').pop() as CSFDColors);\n return color;\n};\n\nexport const getUserReviewDate = (el: HTMLElement): string | null => {\n const dateRaw = el.querySelector('.article-header-date-content .info time').text.trim();\n return parseDate(dateRaw);\n};\n\nexport const getUserReviewUrl = (el: HTMLElement): string => {\n const url = el.querySelector('.film-title-name').attributes.href;\n return `https://www.csfd.cz${url}`;\n};\n\nexport const getUserReviewText = (el: HTMLElement): string => {\n return el.querySelector('.comment').text.trim();\n};\n\nexport const getUserReviewPoster = (el: HTMLElement): string => {\n const img = el.querySelector('.article-img img');\n const srcset = img?.attributes.srcset;\n\n if (srcset) {\n // Extract 3x version from srcset (e.g., \"url 1x, url 2x, url 3x\")\n const srcsetParts = srcset.split(',').map((s) => s.trim());\n const poster3x = srcsetParts.find((s) => s.endsWith('3x'));\n if (poster3x) {\n const url = poster3x.replace(/\\s+3x$/, '').trim();\n return `https:${url}`;\n }\n }\n\n // Fallback to src if srcset not available\n const src = img?.attributes.src;\n return src ? `https:${src}` : null;\n};\n"],"mappings":";;;AAKA,MAAa,mBAAmB,OAA4B;CAC1D,MAAM,MAAM,GAAG,cAAc,mBAAmB,CAAC,WAAW;AAC5D,QAAOA,qCAAe,IAAI;;AAG5B,MAAa,uBAAuB,OAA+B;CACjE,MAAM,aAAa,GAAG,cAAc,sBAAsB,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK;AAGtF,QADe,WAAW,SAAS,SAAS,GAAG,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK,GAAG;;AAIhF,MAAa,qBAAqB,OAAmC;CAEnE,MAAM,WAAW,GAAG,iBAAiB,yBAAyB;AAE9D,QAAOC,oCAAc,SAAS,SAAS,IAAI,SAAS,GAAG,KAAK,MAAM,GAAG,GAAG,GAAG,OAAO;;AAGpF,MAAa,sBAAsB,OAA4B;AAC7D,QAAO,GAAG,cAAc,mBAAmB,CAAC;;AAG9C,MAAa,qBAAqB,OAA4B;CAC5D,MAAM,WAAW,GAAG,cAAc,yBAAyB;AAC3D,QAAO,WAAW,CAAC,SAAS,KAAK,QAAQ,SAAS,GAAG,GAAG;;AAG1D,MAAa,4BAA4B,OAAqC;AAG5E,QADcC,iCADD,GAAG,cAAc,4BAA4B,EAC3B,WAAW,MAAM,IAAI,CAAC,KAAK,CAAe;;AAI3E,MAAa,qBAAqB,OAAmC;AAEnE,QAAOC,gCADS,GAAG,cAAc,0CAA0C,CAAC,KAAK,MAAM,CAC9D;;AAG3B,MAAa,oBAAoB,OAA4B;AAE3D,QAAO,sBADK,GAAG,cAAc,mBAAmB,CAAC,WAAW;;AAI9D,MAAa,qBAAqB,OAA4B;AAC5D,QAAO,GAAG,cAAc,WAAW,CAAC,KAAK,MAAM;;AAGjD,MAAa,uBAAuB,OAA4B;CAC9D,MAAM,MAAM,GAAG,cAAc,mBAAmB;CAChD,MAAM,SAAS,KAAK,WAAW;AAE/B,KAAI,QAAQ;EAGV,MAAM,WADc,OAAO,MAAM,IAAI,CAAC,KAAK,MAAM,EAAE,MAAM,CAAC,CAC7B,MAAM,MAAM,EAAE,SAAS,KAAK,CAAC;AAC1D,MAAI,SAEF,QAAO,SADK,SAAS,QAAQ,UAAU,GAAG,CAAC,MAAM;;CAMrD,MAAM,MAAM,KAAK,WAAW;AAC5B,QAAO,MAAM,SAAS,QAAQ"}
@@ -1,4 +1,4 @@
1
- import { parseColor, parseIdFromUrl } from "./global.helper.mjs";
1
+ import { parseColor, parseDate, parseFilmType, parseIdFromUrl } from "./global.helper.mjs";
2
2
 
3
3
  //#region src/helpers/user-reviews.helper.ts
4
4
  const getUserReviewId = (el) => {
@@ -11,7 +11,7 @@ const getUserReviewRating = (el) => {
11
11
  };
12
12
  const getUserReviewType = (el) => {
13
13
  const typeText = el.querySelectorAll(".film-title-info .info");
14
- return typeText.length > 1 ? typeText[1].text.slice(1, -1) : "film";
14
+ return parseFilmType(typeText.length > 1 ? typeText[1].text.slice(1, -1) : "film");
15
15
  };
16
16
  const getUserReviewTitle = (el) => {
17
17
  return el.querySelector(".film-title-name").text;
@@ -24,7 +24,7 @@ const getUserReviewColorRating = (el) => {
24
24
  return parseColor(el.querySelector(".film-title-inline i.icon")?.classNames.split(" ").pop());
25
25
  };
26
26
  const getUserReviewDate = (el) => {
27
- return el.querySelector(".article-header-date-content .info time").text.trim();
27
+ return parseDate(el.querySelector(".article-header-date-content .info time").text.trim());
28
28
  };
29
29
  const getUserReviewUrl = (el) => {
30
30
  return `https://www.csfd.cz${el.querySelector(".film-title-name").attributes.href}`;