@vicociv/instaloader 0.3.0 → 0.3.2

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.
package/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # @vicociv/instaloader
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/@vicociv/instaloader.svg)](https://www.npmjs.com/package/@vicociv/instaloader)
4
3
  [![npm downloads](https://img.shields.io/npm/dm/@vicociv/instaloader.svg)](https://www.npmjs.com/package/@vicociv/instaloader)
5
4
  [![npm bundle size](https://img.shields.io/bundlephobia/minzip/@vicociv/instaloader)](https://bundlephobia.com/package/@vicociv/instaloader)
5
+ [![dependencies](https://img.shields.io/badge/dependencies-0-brightgreen)](https://bundlephobia.com/package/@vicociv/instaloader)
6
+ [![tree-shaking](https://img.shields.io/badge/tree--shaking-supported-brightgreen)](https://bundlephobia.com/package/@vicociv/instaloader)
6
7
  [![CI](https://github.com/star8ks/instaloader.js/actions/workflows/ci.yml/badge.svg)](https://github.com/star8ks/instaloader.js/actions/workflows/ci.yml)
7
8
  [![codecov](https://codecov.io/gh/star8ks/instaloader.js/branch/main/graph/badge.svg)](https://codecov.io/gh/star8ks/instaloader.js)
8
9
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
@@ -390,6 +391,14 @@ import {
390
391
  } from '@vicociv/instaloader';
391
392
  ```
392
393
 
394
+ ## TODO
395
+
396
+ - [ ] Download comments
397
+ - [ ] Download IGTV
398
+ - [ ] Download Reels
399
+ - [ ] Location support
400
+ - [ ] CLI tool
401
+
393
402
  ## License
394
403
 
395
404
  MIT
package/dist/index.js CHANGED
@@ -326,7 +326,7 @@ var SimpleCookieStore = class {
326
326
  }
327
327
  };
328
328
 
329
- // src/instaloadercontext.ts
329
+ // src/instaloader-context.ts
330
330
  function defaultUserAgent() {
331
331
  return "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36";
332
332
  }
@@ -1174,7 +1174,7 @@ HTTP redirect from ${url} to ${redirectUrl}`);
1174
1174
  }
1175
1175
  };
1176
1176
 
1177
- // src/nodeiterator.ts
1177
+ // src/node-iterator.ts
1178
1178
  var import_crypto = require("crypto");
1179
1179
  var FrozenNodeIterator = class _FrozenNodeIterator {
1180
1180
  queryHash;
@@ -1441,7 +1441,7 @@ var NodeIterator = class _NodeIterator {
1441
1441
  }
1442
1442
  };
1443
1443
  async function resumableIteration(options) {
1444
- const { context, iterator, load, save: _save, formatPath, checkBbd = true, enabled = true } = options;
1444
+ const { context, iterator, load, formatPath, checkBbd = true, enabled = true } = options;
1445
1445
  if (!enabled || !(iterator instanceof NodeIterator)) {
1446
1446
  return { isResuming: false, startIndex: 0 };
1447
1447
  }
@@ -1480,9 +1480,7 @@ function optionalNormalize(str) {
1480
1480
  }
1481
1481
  function shortcodeToMediaid(code) {
1482
1482
  if (code.length > 11) {
1483
- throw new InvalidArgumentException(
1484
- `Wrong shortcode "${code}", unable to convert to mediaid.`
1485
- );
1483
+ throw new InvalidArgumentException(`Wrong shortcode "${code}", unable to convert to mediaid.`);
1486
1484
  }
1487
1485
  const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
1488
1486
  let mediaid = BigInt(0);
@@ -1610,10 +1608,7 @@ var PostComment = class _PostComment {
1610
1608
  get owner() {
1611
1609
  if ("iphone_struct" in this._node) {
1612
1610
  const iphoneStruct = this._node["iphone_struct"];
1613
- return Profile.fromIphoneStruct(
1614
- this._context,
1615
- iphoneStruct["user"]
1616
- );
1611
+ return Profile.fromIphoneStruct(this._context, iphoneStruct["user"]);
1617
1612
  }
1618
1613
  return new Profile(this._context, this._node["owner"]);
1619
1614
  }
@@ -1716,9 +1711,9 @@ var Post = class _Post {
1716
1711
  const carouselMedia = media["carousel_media"];
1717
1712
  if (carouselMedia) {
1718
1713
  fakeNode["edge_sidecar_to_children"] = {
1719
- edges: carouselMedia.map(
1720
- (node) => ({ node: _Post._convertIphoneCarousel(node, mediaTypes) })
1721
- )
1714
+ edges: carouselMedia.map((node) => ({
1715
+ node: _Post._convertIphoneCarousel(node, mediaTypes)
1716
+ }))
1722
1717
  };
1723
1718
  }
1724
1719
  } catch {
@@ -1770,10 +1765,9 @@ var Post = class _Post {
1770
1765
  }
1771
1766
  async _obtainMetadata() {
1772
1767
  if (!this._full_metadata_dict) {
1773
- const result = await this._context.doc_id_graphql_query(
1774
- "8845758582119845",
1775
- { shortcode: this.shortcode }
1776
- );
1768
+ const result = await this._context.doc_id_graphql_query("8845758582119845", {
1769
+ shortcode: this.shortcode
1770
+ });
1777
1771
  const data = result["data"];
1778
1772
  const picJson = data["xdt_shortcode_media"];
1779
1773
  if (picJson === null) {
@@ -1786,9 +1780,7 @@ var Post = class _Post {
1786
1780
  };
1787
1781
  const typename = picJson["__typename"];
1788
1782
  if (!(typename in xdtTypes)) {
1789
- throw new BadResponseException(
1790
- `Unknown __typename in metadata: ${typename}.`
1791
- );
1783
+ throw new BadResponseException(`Unknown __typename in metadata: ${typename}.`);
1792
1784
  }
1793
1785
  picJson["__typename"] = xdtTypes[typename];
1794
1786
  this._full_metadata_dict = picJson;
@@ -1812,15 +1804,10 @@ var Post = class _Post {
1812
1804
  throw new IPhoneSupportDisabledException("iPhone support is disabled.");
1813
1805
  }
1814
1806
  if (!this._context.is_logged_in) {
1815
- throw new LoginRequiredException(
1816
- "Login required to access iPhone media info endpoint."
1817
- );
1807
+ throw new LoginRequiredException("Login required to access iPhone media info endpoint.");
1818
1808
  }
1819
1809
  if (!this._iphone_struct_) {
1820
- const data = await this._context.get_iphone_json(
1821
- `api/v1/media/${this.mediaid}/info/`,
1822
- {}
1823
- );
1810
+ const data = await this._context.get_iphone_json(`api/v1/media/${this.mediaid}/info/`, {});
1824
1811
  const items = data["items"];
1825
1812
  this._iphone_struct_ = items[0];
1826
1813
  }
@@ -1844,9 +1831,7 @@ var Post = class _Post {
1844
1831
  }
1845
1832
  return d;
1846
1833
  } catch {
1847
- throw new Error(
1848
- `Field ${keys.join(".")} not found. Use async method for full metadata.`
1849
- );
1834
+ throw new Error(`Field ${keys.join(".")} not found. Use async method for full metadata.`);
1850
1835
  }
1851
1836
  }
1852
1837
  /**
@@ -1933,10 +1918,7 @@ var Post = class _Post {
1933
1918
  get mediacount() {
1934
1919
  if (this.typename === "GraphSidecar") {
1935
1920
  try {
1936
- const edges = this._field(
1937
- "edge_sidecar_to_children",
1938
- "edges"
1939
- );
1921
+ const edges = this._field("edge_sidecar_to_children", "edges");
1940
1922
  return edges.length;
1941
1923
  } catch {
1942
1924
  return 1;
@@ -1989,10 +1971,7 @@ var Post = class _Post {
1989
1971
  /** List of all lowercased users that are tagged in the Post. */
1990
1972
  get tagged_users() {
1991
1973
  try {
1992
- const edges = this._field(
1993
- "edge_media_to_tagged_user",
1994
- "edges"
1995
- );
1974
+ const edges = this._field("edge_media_to_tagged_user", "edges");
1996
1975
  return edges.map((edge) => {
1997
1976
  const e = edge;
1998
1977
  const node = e["node"];
@@ -2082,10 +2061,7 @@ var Post = class _Post {
2082
2061
  /** Whether Post is a sponsored post. */
2083
2062
  get is_sponsored() {
2084
2063
  try {
2085
- const sponsorEdges = this._field(
2086
- "edge_media_to_sponsor_user",
2087
- "edges"
2088
- );
2064
+ const sponsorEdges = this._field("edge_media_to_sponsor_user", "edges");
2089
2065
  return sponsorEdges.length > 0;
2090
2066
  } catch {
2091
2067
  return false;
@@ -2095,10 +2071,7 @@ var Post = class _Post {
2095
2071
  getIsVideos() {
2096
2072
  if (this.typename === "GraphSidecar") {
2097
2073
  try {
2098
- const edges = this._field(
2099
- "edge_sidecar_to_children",
2100
- "edges"
2101
- );
2074
+ const edges = this._field("edge_sidecar_to_children", "edges");
2102
2075
  return edges.map((edge) => {
2103
2076
  const e = edge;
2104
2077
  const node = e["node"];
@@ -2116,10 +2089,7 @@ var Post = class _Post {
2116
2089
  return;
2117
2090
  }
2118
2091
  try {
2119
- const edges = this._field(
2120
- "edge_sidecar_to_children",
2121
- "edges"
2122
- );
2092
+ const edges = this._field("edge_sidecar_to_children", "edges");
2123
2093
  const actualEnd = end < 0 ? edges.length - 1 : end;
2124
2094
  const actualStart = start < 0 ? edges.length - 1 : start;
2125
2095
  for (let idx = 0; idx < edges.length; idx++) {
@@ -2244,9 +2214,7 @@ var Profile = class _Profile {
2244
2214
  const data = metadata["data"];
2245
2215
  const user = data["user"];
2246
2216
  if (user === null) {
2247
- throw new ProfileNotExistsException(
2248
- `Profile ${this.username} does not exist.`
2249
- );
2217
+ throw new ProfileNotExistsException(`Profile ${this.username} does not exist.`);
2250
2218
  }
2251
2219
  this._node = user;
2252
2220
  this._has_full_metadata = true;
@@ -2271,9 +2239,7 @@ var Profile = class _Profile {
2271
2239
  The most similar profile${plural}: ${profiles.slice(0, 5).join(", ")}.`
2272
2240
  );
2273
2241
  }
2274
- throw new ProfileNotExistsException(
2275
- `Profile ${this.username} does not exist.`
2276
- );
2242
+ throw new ProfileNotExistsException(`Profile ${this.username} does not exist.`);
2277
2243
  }
2278
2244
  throw err;
2279
2245
  }
@@ -2418,10 +2384,7 @@ The most similar profile${plural}: ${profiles.slice(0, 5).join(", ")}.`
2418
2384
  if (this._context.iphoneSupport && this._context.is_logged_in) {
2419
2385
  try {
2420
2386
  if (!this._iphone_struct_) {
2421
- const data = await this._context.get_iphone_json(
2422
- `api/v1/users/${this.userid}/info/`,
2423
- {}
2424
- );
2387
+ const data = await this._context.get_iphone_json(`api/v1/users/${this.userid}/info/`, {});
2425
2388
  this._iphone_struct_ = data["user"];
2426
2389
  }
2427
2390
  const hdInfo = this._iphone_struct_["hd_profile_pic_url_info"];
@@ -2458,7 +2421,9 @@ The most similar profile${plural}: ${profiles.slice(0, 5).join(", ")}.`
2458
2421
  const edgeData = this._metadata("edge_owner_to_timeline_media");
2459
2422
  const countValue = edgeData["count"];
2460
2423
  const baseData = {
2461
- edges: (edgeData["edges"] || []).map((e) => ({ node: e["node"] || e })),
2424
+ edges: (edgeData["edges"] || []).map((e) => ({
2425
+ node: e["node"] || e
2426
+ })),
2462
2427
  page_info: edgeData["page_info"] || { has_next_page: false, end_cursor: null }
2463
2428
  };
2464
2429
  firstData = typeof countValue === "number" ? { ...baseData, count: countValue } : baseData;
@@ -2559,10 +2524,9 @@ var StoryItem = class _StoryItem {
2559
2524
  * Create a StoryItem object from a given mediaid.
2560
2525
  */
2561
2526
  static async fromMediaid(context, mediaid) {
2562
- const picJson = await context.graphql_query(
2563
- "2b0673e0dc4580674a88d426fe00ea90",
2564
- { shortcode: mediaidToShortcode(mediaid) }
2565
- );
2527
+ const picJson = await context.graphql_query("2b0673e0dc4580674a88d426fe00ea90", {
2528
+ shortcode: mediaidToShortcode(mediaid)
2529
+ });
2566
2530
  const shortcodeMedia = picJson["data"]["shortcode_media"];
2567
2531
  if (shortcodeMedia === null) {
2568
2532
  throw new BadResponseException("Fetching StoryItem metadata failed.");
@@ -2587,10 +2551,7 @@ var StoryItem = class _StoryItem {
2587
2551
  async getOwnerProfile() {
2588
2552
  if (!this._owner_profile) {
2589
2553
  const owner = this._node["owner"];
2590
- this._owner_profile = await Profile.fromId(
2591
- this._context,
2592
- Number(owner["id"])
2593
- );
2554
+ this._owner_profile = await Profile.fromId(this._context, Number(owner["id"]));
2594
2555
  }
2595
2556
  return this._owner_profile;
2596
2557
  }
@@ -2751,10 +2712,7 @@ var Story = class {
2751
2712
  /** Profile instance of the story owner. */
2752
2713
  get owner_profile() {
2753
2714
  if (!this._owner_profile) {
2754
- this._owner_profile = new Profile(
2755
- this._context,
2756
- this._node["user"]
2757
- );
2715
+ this._owner_profile = new Profile(this._context, this._node["user"]);
2758
2716
  }
2759
2717
  return this._owner_profile;
2760
2718
  }
@@ -2812,10 +2770,7 @@ var Highlight = class extends Story {
2812
2770
  /** Profile instance of the highlights' owner. */
2813
2771
  get owner_profile() {
2814
2772
  if (!this._owner_profile) {
2815
- this._owner_profile = new Profile(
2816
- this._context,
2817
- this._node["owner"]
2818
- );
2773
+ this._owner_profile = new Profile(this._context, this._node["owner"]);
2819
2774
  }
2820
2775
  return this._owner_profile;
2821
2776
  }
@@ -2835,16 +2790,13 @@ var Highlight = class extends Story {
2835
2790
  }
2836
2791
  async _fetchItems() {
2837
2792
  if (!this._items) {
2838
- const data = await this._context.graphql_query(
2839
- "45246d3fe16ccc6577e0bd297a5db1ab",
2840
- {
2841
- reel_ids: [],
2842
- tag_names: [],
2843
- location_ids: [],
2844
- highlight_reel_ids: [String(this.unique_id)],
2845
- precomposed_overlay: false
2846
- }
2847
- );
2793
+ const data = await this._context.graphql_query("45246d3fe16ccc6577e0bd297a5db1ab", {
2794
+ reel_ids: [],
2795
+ tag_names: [],
2796
+ location_ids: [],
2797
+ highlight_reel_ids: [String(this.unique_id)],
2798
+ precomposed_overlay: false
2799
+ });
2848
2800
  const dataObj = data["data"];
2849
2801
  const reelsMedia = dataObj["reels_media"];
2850
2802
  const firstReel = reelsMedia[0];
@@ -2918,10 +2870,10 @@ var Hashtag = class _Hashtag {
2918
2870
  return this._node["name"].toLowerCase();
2919
2871
  }
2920
2872
  async _query(params) {
2921
- const jsonResponse = await this._context.get_iphone_json(
2922
- "api/v1/tags/web_info/",
2923
- { ...params, tag_name: this.name }
2924
- );
2873
+ const jsonResponse = await this._context.get_iphone_json("api/v1/tags/web_info/", {
2874
+ ...params,
2875
+ tag_name: this.name
2876
+ });
2925
2877
  if ("graphql" in jsonResponse) {
2926
2878
  return jsonResponse["graphql"]["hashtag"];
2927
2879
  }
@@ -2999,10 +2951,7 @@ var Hashtag = class _Hashtag {
2999
2951
  /** Yields the top posts of the hashtag. */
3000
2952
  async *getTopPosts() {
3001
2953
  try {
3002
- const edges = await this.getMetadata(
3003
- "edge_hashtag_to_top_posts",
3004
- "edges"
3005
- );
2954
+ const edges = await this.getMetadata("edge_hashtag_to_top_posts", "edges");
3006
2955
  for (const edge of edges) {
3007
2956
  const e = edge;
3008
2957
  yield new Post(this._context, e["node"]);
@@ -3188,9 +3137,7 @@ function loadStructure(context, jsonStructure) {
3188
3137
  if ("shortcode" in jsonStructure) {
3189
3138
  return new Post(context, jsonStructure);
3190
3139
  }
3191
- throw new InvalidArgumentException(
3192
- "Passed json structure is not an Instaloader JSON"
3193
- );
3140
+ throw new InvalidArgumentException("Passed json structure is not an Instaloader JSON");
3194
3141
  }
3195
3142
 
3196
3143
  // src/instaloader.ts
package/dist/index.mjs CHANGED
@@ -238,7 +238,7 @@ var SimpleCookieStore = class {
238
238
  }
239
239
  };
240
240
 
241
- // src/instaloadercontext.ts
241
+ // src/instaloader-context.ts
242
242
  function defaultUserAgent() {
243
243
  return "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36";
244
244
  }
@@ -1086,7 +1086,7 @@ HTTP redirect from ${url} to ${redirectUrl}`);
1086
1086
  }
1087
1087
  };
1088
1088
 
1089
- // src/nodeiterator.ts
1089
+ // src/node-iterator.ts
1090
1090
  import { createHash } from "crypto";
1091
1091
  var FrozenNodeIterator = class _FrozenNodeIterator {
1092
1092
  queryHash;
@@ -1353,7 +1353,7 @@ var NodeIterator = class _NodeIterator {
1353
1353
  }
1354
1354
  };
1355
1355
  async function resumableIteration(options) {
1356
- const { context, iterator, load, save: _save, formatPath, checkBbd = true, enabled = true } = options;
1356
+ const { context, iterator, load, formatPath, checkBbd = true, enabled = true } = options;
1357
1357
  if (!enabled || !(iterator instanceof NodeIterator)) {
1358
1358
  return { isResuming: false, startIndex: 0 };
1359
1359
  }
@@ -1392,9 +1392,7 @@ function optionalNormalize(str) {
1392
1392
  }
1393
1393
  function shortcodeToMediaid(code) {
1394
1394
  if (code.length > 11) {
1395
- throw new InvalidArgumentException(
1396
- `Wrong shortcode "${code}", unable to convert to mediaid.`
1397
- );
1395
+ throw new InvalidArgumentException(`Wrong shortcode "${code}", unable to convert to mediaid.`);
1398
1396
  }
1399
1397
  const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
1400
1398
  let mediaid = BigInt(0);
@@ -1522,10 +1520,7 @@ var PostComment = class _PostComment {
1522
1520
  get owner() {
1523
1521
  if ("iphone_struct" in this._node) {
1524
1522
  const iphoneStruct = this._node["iphone_struct"];
1525
- return Profile.fromIphoneStruct(
1526
- this._context,
1527
- iphoneStruct["user"]
1528
- );
1523
+ return Profile.fromIphoneStruct(this._context, iphoneStruct["user"]);
1529
1524
  }
1530
1525
  return new Profile(this._context, this._node["owner"]);
1531
1526
  }
@@ -1628,9 +1623,9 @@ var Post = class _Post {
1628
1623
  const carouselMedia = media["carousel_media"];
1629
1624
  if (carouselMedia) {
1630
1625
  fakeNode["edge_sidecar_to_children"] = {
1631
- edges: carouselMedia.map(
1632
- (node) => ({ node: _Post._convertIphoneCarousel(node, mediaTypes) })
1633
- )
1626
+ edges: carouselMedia.map((node) => ({
1627
+ node: _Post._convertIphoneCarousel(node, mediaTypes)
1628
+ }))
1634
1629
  };
1635
1630
  }
1636
1631
  } catch {
@@ -1682,10 +1677,9 @@ var Post = class _Post {
1682
1677
  }
1683
1678
  async _obtainMetadata() {
1684
1679
  if (!this._full_metadata_dict) {
1685
- const result = await this._context.doc_id_graphql_query(
1686
- "8845758582119845",
1687
- { shortcode: this.shortcode }
1688
- );
1680
+ const result = await this._context.doc_id_graphql_query("8845758582119845", {
1681
+ shortcode: this.shortcode
1682
+ });
1689
1683
  const data = result["data"];
1690
1684
  const picJson = data["xdt_shortcode_media"];
1691
1685
  if (picJson === null) {
@@ -1698,9 +1692,7 @@ var Post = class _Post {
1698
1692
  };
1699
1693
  const typename = picJson["__typename"];
1700
1694
  if (!(typename in xdtTypes)) {
1701
- throw new BadResponseException(
1702
- `Unknown __typename in metadata: ${typename}.`
1703
- );
1695
+ throw new BadResponseException(`Unknown __typename in metadata: ${typename}.`);
1704
1696
  }
1705
1697
  picJson["__typename"] = xdtTypes[typename];
1706
1698
  this._full_metadata_dict = picJson;
@@ -1724,15 +1716,10 @@ var Post = class _Post {
1724
1716
  throw new IPhoneSupportDisabledException("iPhone support is disabled.");
1725
1717
  }
1726
1718
  if (!this._context.is_logged_in) {
1727
- throw new LoginRequiredException(
1728
- "Login required to access iPhone media info endpoint."
1729
- );
1719
+ throw new LoginRequiredException("Login required to access iPhone media info endpoint.");
1730
1720
  }
1731
1721
  if (!this._iphone_struct_) {
1732
- const data = await this._context.get_iphone_json(
1733
- `api/v1/media/${this.mediaid}/info/`,
1734
- {}
1735
- );
1722
+ const data = await this._context.get_iphone_json(`api/v1/media/${this.mediaid}/info/`, {});
1736
1723
  const items = data["items"];
1737
1724
  this._iphone_struct_ = items[0];
1738
1725
  }
@@ -1756,9 +1743,7 @@ var Post = class _Post {
1756
1743
  }
1757
1744
  return d;
1758
1745
  } catch {
1759
- throw new Error(
1760
- `Field ${keys.join(".")} not found. Use async method for full metadata.`
1761
- );
1746
+ throw new Error(`Field ${keys.join(".")} not found. Use async method for full metadata.`);
1762
1747
  }
1763
1748
  }
1764
1749
  /**
@@ -1845,10 +1830,7 @@ var Post = class _Post {
1845
1830
  get mediacount() {
1846
1831
  if (this.typename === "GraphSidecar") {
1847
1832
  try {
1848
- const edges = this._field(
1849
- "edge_sidecar_to_children",
1850
- "edges"
1851
- );
1833
+ const edges = this._field("edge_sidecar_to_children", "edges");
1852
1834
  return edges.length;
1853
1835
  } catch {
1854
1836
  return 1;
@@ -1901,10 +1883,7 @@ var Post = class _Post {
1901
1883
  /** List of all lowercased users that are tagged in the Post. */
1902
1884
  get tagged_users() {
1903
1885
  try {
1904
- const edges = this._field(
1905
- "edge_media_to_tagged_user",
1906
- "edges"
1907
- );
1886
+ const edges = this._field("edge_media_to_tagged_user", "edges");
1908
1887
  return edges.map((edge) => {
1909
1888
  const e = edge;
1910
1889
  const node = e["node"];
@@ -1994,10 +1973,7 @@ var Post = class _Post {
1994
1973
  /** Whether Post is a sponsored post. */
1995
1974
  get is_sponsored() {
1996
1975
  try {
1997
- const sponsorEdges = this._field(
1998
- "edge_media_to_sponsor_user",
1999
- "edges"
2000
- );
1976
+ const sponsorEdges = this._field("edge_media_to_sponsor_user", "edges");
2001
1977
  return sponsorEdges.length > 0;
2002
1978
  } catch {
2003
1979
  return false;
@@ -2007,10 +1983,7 @@ var Post = class _Post {
2007
1983
  getIsVideos() {
2008
1984
  if (this.typename === "GraphSidecar") {
2009
1985
  try {
2010
- const edges = this._field(
2011
- "edge_sidecar_to_children",
2012
- "edges"
2013
- );
1986
+ const edges = this._field("edge_sidecar_to_children", "edges");
2014
1987
  return edges.map((edge) => {
2015
1988
  const e = edge;
2016
1989
  const node = e["node"];
@@ -2028,10 +2001,7 @@ var Post = class _Post {
2028
2001
  return;
2029
2002
  }
2030
2003
  try {
2031
- const edges = this._field(
2032
- "edge_sidecar_to_children",
2033
- "edges"
2034
- );
2004
+ const edges = this._field("edge_sidecar_to_children", "edges");
2035
2005
  const actualEnd = end < 0 ? edges.length - 1 : end;
2036
2006
  const actualStart = start < 0 ? edges.length - 1 : start;
2037
2007
  for (let idx = 0; idx < edges.length; idx++) {
@@ -2156,9 +2126,7 @@ var Profile = class _Profile {
2156
2126
  const data = metadata["data"];
2157
2127
  const user = data["user"];
2158
2128
  if (user === null) {
2159
- throw new ProfileNotExistsException(
2160
- `Profile ${this.username} does not exist.`
2161
- );
2129
+ throw new ProfileNotExistsException(`Profile ${this.username} does not exist.`);
2162
2130
  }
2163
2131
  this._node = user;
2164
2132
  this._has_full_metadata = true;
@@ -2183,9 +2151,7 @@ var Profile = class _Profile {
2183
2151
  The most similar profile${plural}: ${profiles.slice(0, 5).join(", ")}.`
2184
2152
  );
2185
2153
  }
2186
- throw new ProfileNotExistsException(
2187
- `Profile ${this.username} does not exist.`
2188
- );
2154
+ throw new ProfileNotExistsException(`Profile ${this.username} does not exist.`);
2189
2155
  }
2190
2156
  throw err;
2191
2157
  }
@@ -2330,10 +2296,7 @@ The most similar profile${plural}: ${profiles.slice(0, 5).join(", ")}.`
2330
2296
  if (this._context.iphoneSupport && this._context.is_logged_in) {
2331
2297
  try {
2332
2298
  if (!this._iphone_struct_) {
2333
- const data = await this._context.get_iphone_json(
2334
- `api/v1/users/${this.userid}/info/`,
2335
- {}
2336
- );
2299
+ const data = await this._context.get_iphone_json(`api/v1/users/${this.userid}/info/`, {});
2337
2300
  this._iphone_struct_ = data["user"];
2338
2301
  }
2339
2302
  const hdInfo = this._iphone_struct_["hd_profile_pic_url_info"];
@@ -2370,7 +2333,9 @@ The most similar profile${plural}: ${profiles.slice(0, 5).join(", ")}.`
2370
2333
  const edgeData = this._metadata("edge_owner_to_timeline_media");
2371
2334
  const countValue = edgeData["count"];
2372
2335
  const baseData = {
2373
- edges: (edgeData["edges"] || []).map((e) => ({ node: e["node"] || e })),
2336
+ edges: (edgeData["edges"] || []).map((e) => ({
2337
+ node: e["node"] || e
2338
+ })),
2374
2339
  page_info: edgeData["page_info"] || { has_next_page: false, end_cursor: null }
2375
2340
  };
2376
2341
  firstData = typeof countValue === "number" ? { ...baseData, count: countValue } : baseData;
@@ -2471,10 +2436,9 @@ var StoryItem = class _StoryItem {
2471
2436
  * Create a StoryItem object from a given mediaid.
2472
2437
  */
2473
2438
  static async fromMediaid(context, mediaid) {
2474
- const picJson = await context.graphql_query(
2475
- "2b0673e0dc4580674a88d426fe00ea90",
2476
- { shortcode: mediaidToShortcode(mediaid) }
2477
- );
2439
+ const picJson = await context.graphql_query("2b0673e0dc4580674a88d426fe00ea90", {
2440
+ shortcode: mediaidToShortcode(mediaid)
2441
+ });
2478
2442
  const shortcodeMedia = picJson["data"]["shortcode_media"];
2479
2443
  if (shortcodeMedia === null) {
2480
2444
  throw new BadResponseException("Fetching StoryItem metadata failed.");
@@ -2499,10 +2463,7 @@ var StoryItem = class _StoryItem {
2499
2463
  async getOwnerProfile() {
2500
2464
  if (!this._owner_profile) {
2501
2465
  const owner = this._node["owner"];
2502
- this._owner_profile = await Profile.fromId(
2503
- this._context,
2504
- Number(owner["id"])
2505
- );
2466
+ this._owner_profile = await Profile.fromId(this._context, Number(owner["id"]));
2506
2467
  }
2507
2468
  return this._owner_profile;
2508
2469
  }
@@ -2663,10 +2624,7 @@ var Story = class {
2663
2624
  /** Profile instance of the story owner. */
2664
2625
  get owner_profile() {
2665
2626
  if (!this._owner_profile) {
2666
- this._owner_profile = new Profile(
2667
- this._context,
2668
- this._node["user"]
2669
- );
2627
+ this._owner_profile = new Profile(this._context, this._node["user"]);
2670
2628
  }
2671
2629
  return this._owner_profile;
2672
2630
  }
@@ -2724,10 +2682,7 @@ var Highlight = class extends Story {
2724
2682
  /** Profile instance of the highlights' owner. */
2725
2683
  get owner_profile() {
2726
2684
  if (!this._owner_profile) {
2727
- this._owner_profile = new Profile(
2728
- this._context,
2729
- this._node["owner"]
2730
- );
2685
+ this._owner_profile = new Profile(this._context, this._node["owner"]);
2731
2686
  }
2732
2687
  return this._owner_profile;
2733
2688
  }
@@ -2747,16 +2702,13 @@ var Highlight = class extends Story {
2747
2702
  }
2748
2703
  async _fetchItems() {
2749
2704
  if (!this._items) {
2750
- const data = await this._context.graphql_query(
2751
- "45246d3fe16ccc6577e0bd297a5db1ab",
2752
- {
2753
- reel_ids: [],
2754
- tag_names: [],
2755
- location_ids: [],
2756
- highlight_reel_ids: [String(this.unique_id)],
2757
- precomposed_overlay: false
2758
- }
2759
- );
2705
+ const data = await this._context.graphql_query("45246d3fe16ccc6577e0bd297a5db1ab", {
2706
+ reel_ids: [],
2707
+ tag_names: [],
2708
+ location_ids: [],
2709
+ highlight_reel_ids: [String(this.unique_id)],
2710
+ precomposed_overlay: false
2711
+ });
2760
2712
  const dataObj = data["data"];
2761
2713
  const reelsMedia = dataObj["reels_media"];
2762
2714
  const firstReel = reelsMedia[0];
@@ -2830,10 +2782,10 @@ var Hashtag = class _Hashtag {
2830
2782
  return this._node["name"].toLowerCase();
2831
2783
  }
2832
2784
  async _query(params) {
2833
- const jsonResponse = await this._context.get_iphone_json(
2834
- "api/v1/tags/web_info/",
2835
- { ...params, tag_name: this.name }
2836
- );
2785
+ const jsonResponse = await this._context.get_iphone_json("api/v1/tags/web_info/", {
2786
+ ...params,
2787
+ tag_name: this.name
2788
+ });
2837
2789
  if ("graphql" in jsonResponse) {
2838
2790
  return jsonResponse["graphql"]["hashtag"];
2839
2791
  }
@@ -2911,10 +2863,7 @@ var Hashtag = class _Hashtag {
2911
2863
  /** Yields the top posts of the hashtag. */
2912
2864
  async *getTopPosts() {
2913
2865
  try {
2914
- const edges = await this.getMetadata(
2915
- "edge_hashtag_to_top_posts",
2916
- "edges"
2917
- );
2866
+ const edges = await this.getMetadata("edge_hashtag_to_top_posts", "edges");
2918
2867
  for (const edge of edges) {
2919
2868
  const e = edge;
2920
2869
  yield new Post(this._context, e["node"]);
@@ -3100,9 +3049,7 @@ function loadStructure(context, jsonStructure) {
3100
3049
  if ("shortcode" in jsonStructure) {
3101
3050
  return new Post(context, jsonStructure);
3102
3051
  }
3103
- throw new InvalidArgumentException(
3104
- "Passed json structure is not an Instaloader JSON"
3105
- );
3052
+ throw new InvalidArgumentException("Passed json structure is not an Instaloader JSON");
3106
3053
  }
3107
3054
 
3108
3055
  // src/instaloader.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vicociv/instaloader",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "TypeScript port of instaloader - Download pictures (or videos) along with their captions and other metadata from Instagram.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",