@the-convocation/twitter-scraper 0.18.0 → 0.18.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.
@@ -892,6 +892,12 @@ async function getProfile(username, auth) {
892
892
  }
893
893
  const { result: user } = value.data.user;
894
894
  const { legacy } = user;
895
+ if (user.__typename === "UserUnavailable" && user?.reason === "Suspended") {
896
+ return {
897
+ success: false,
898
+ err: new Error("User is suspended.")
899
+ };
900
+ }
895
901
  if (user.rest_id == null || user.rest_id.length === 0) {
896
902
  return {
897
903
  success: false,
@@ -1014,8 +1020,10 @@ function parseMediaGroups(media) {
1014
1020
  url: m.media_url_https,
1015
1021
  alt_text: m.ext_alt_text
1016
1022
  });
1017
- } else if (m.type === "video" || m.type === "animated_gif") {
1023
+ } else if (m.type === "video") {
1018
1024
  videos.push(parseVideo(m));
1025
+ } else if (m.type === "animated_gif") {
1026
+ videos.push(parseGif(m));
1019
1027
  }
1020
1028
  const sensitive = m.ext_sensitive_media_warning;
1021
1029
  if (sensitive != null) {
@@ -1024,6 +1032,19 @@ function parseMediaGroups(media) {
1024
1032
  }
1025
1033
  return { sensitiveContent, photos, videos };
1026
1034
  }
1035
+ function parseGif(m) {
1036
+ const gif = {
1037
+ id: m.id_str,
1038
+ preview: m.media_url_https
1039
+ };
1040
+ const variants = m.video_info?.variants ?? [];
1041
+ const url = variants.find((v) => v.content_type === "video/mp4")?.url;
1042
+ if (url) {
1043
+ gif.preview = url;
1044
+ gif.url = url;
1045
+ }
1046
+ return gif;
1047
+ }
1027
1048
  function parseVideo(m) {
1028
1049
  const video = {
1029
1050
  id: m.id_str,