podverse-external-services 5.1.1-alpha.7 → 5.1.1-alpha.8

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.
@@ -11,6 +11,7 @@ export declare class PodcastIndexService {
11
11
  constructor({ authKey, baseUrl, secretKey }: Constructor);
12
12
  podcastIndexAPIRequest: (url: string, config?: any) => Promise<any>;
13
13
  deadFeedsDownloadAndExtractCSV: () => Promise<any[]>;
14
+ podcastGetById: (podcastIndexId: number) => Promise<any | null>;
14
15
  podcastGetByGuid: (podcastGuid: string) => Promise<PodcastByGuidResponse | null>;
15
16
  recentGetData: (sinceRange: number) => Promise<any[]>;
16
17
  trendingGetPodcasts: (max?: number, since?: number, lang?: string, cat?: string) => Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/podcast-index/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAG9D,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AASD,qBAAa,mBAAmB;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;gBAEZ,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,WAAW;IAQzD,sBAAsB,GAAU,KAAK,MAAM,EAAE,SAAS,GAAG,kBA0BxD;IAID,8BAA8B,QAAa,OAAO,CAAC,GAAG,EAAE,CAAC,CAwCxD;IAID,gBAAgB,GAAU,aAAa,MAAM,KAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAYpF;IAID,aAAa,GAAU,YAAY,MAAM,oBA4BxC;IAID,mBAAmB,GACjB,MAAK,MAAW,EAChB,QAAQ,MAAM,EACd,OAAO,MAAM,EACb,MAAM,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Aa,OAAO,CAAC,MAAM,EAAE,CAAC,CAMjD;IAED,+BAA+B,GAC7B,4BAA4B,MAAM,EAAE,EAAE,gBAAW,KAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAatE;CACF"}
@@ -32,12 +32,16 @@ class PodcastIndexService {
32
32
  var _a, _b, _c;
33
33
  const apiHeaderTime = Math.floor(Date.now() / 1000);
34
34
  const hash = (0, sha1_1.default)(this.authKey + this.secretKey + apiHeaderTime).toString(enc_hex_1.default);
35
+ const shouldPreventHeaders = (config === null || config === void 0 ? void 0 : config.preventHeaders) || false;
36
+ config === null || config === void 0 ? true : delete config.preventHeaders;
35
37
  try {
36
- const response = yield (0, podverse_helpers_1.request)(url, Object.assign({ headers: {
38
+ const response = yield (0, podverse_helpers_1.request)(url, Object.assign(Object.assign({}, (shouldPreventHeaders ? {} : {
39
+ headers: {
37
40
  'X-Auth-Key': this.authKey,
38
41
  'X-Auth-Date': apiHeaderTime,
39
42
  Authorization: hash
40
- } }, config));
43
+ }
44
+ })), config));
41
45
  return response;
42
46
  }
43
47
  catch (error) {
@@ -60,7 +64,7 @@ class PodcastIndexService {
60
64
  if (!fs_1.default.existsSync(tmpDir)) {
61
65
  fs_1.default.mkdirSync(tmpDir);
62
66
  }
63
- const data = yield this.podcastIndexAPIRequest(url, { responseType: 'stream' });
67
+ const data = yield this.podcastIndexAPIRequest(url, { preventHeaders: true, responseType: 'stream' });
64
68
  const writer = fs_1.default.createWriteStream(filePath);
65
69
  data.pipe(writer);
66
70
  yield new Promise((resolve, reject) => {
@@ -77,15 +81,25 @@ class PodcastIndexService {
77
81
  });
78
82
  fs_1.default.unlinkSync(filePath);
79
83
  const parsedResults = results.map((row) => {
80
- const [id, duplicateOf] = Object.values(row).map((value) => value.trim());
84
+ const [id_to_remove, duplicate_id_to_keep] = Object.values(row).map((value) => value.trim());
81
85
  return {
82
- podcast_index_id: parseInt(id, 10),
83
- duplicateOf: duplicateOf ? parseInt(duplicateOf, 10) : null
86
+ id_to_remove: parseInt(id_to_remove, 10),
87
+ duplicate_id_to_keep: duplicate_id_to_keep ? parseInt(duplicate_id_to_keep, 10) : null
84
88
  };
85
89
  });
86
90
  return parsedResults;
87
91
  });
88
92
  // Podcast
93
+ this.podcastGetById = (podcastIndexId) => __awaiter(this, void 0, void 0, function* () {
94
+ const url = `${this.baseUrl}/podcasts/byfeedid?id=${podcastIndexId}`;
95
+ try {
96
+ const response = yield this.podcastIndexAPIRequest(url);
97
+ return response || null;
98
+ }
99
+ catch (error) {
100
+ return null;
101
+ }
102
+ });
89
103
  this.podcastGetByGuid = (podcastGuid) => __awaiter(this, void 0, void 0, function* () {
90
104
  const url = `${this.baseUrl}/podcasts/byguid?guid=${podcastGuid}`;
91
105
  let podcastIndexPodcast = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "podverse-external-services",
3
- "version": "5.1.1-alpha.7",
3
+ "version": "5.1.1-alpha.8",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",