@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.
@@ -913,6 +913,12 @@ async function getProfile(username, auth) {
913
913
  }
914
914
  const { result: user } = value.data.user;
915
915
  const { legacy } = user;
916
+ if (user.__typename === "UserUnavailable" && user?.reason === "Suspended") {
917
+ return {
918
+ success: false,
919
+ err: new Error("User is suspended.")
920
+ };
921
+ }
916
922
  if (user.rest_id == null || user.rest_id.length === 0) {
917
923
  return {
918
924
  success: false,
@@ -1035,8 +1041,10 @@ function parseMediaGroups(media) {
1035
1041
  url: m.media_url_https,
1036
1042
  alt_text: m.ext_alt_text
1037
1043
  });
1038
- } else if (m.type === "video" || m.type === "animated_gif") {
1044
+ } else if (m.type === "video") {
1039
1045
  videos.push(parseVideo(m));
1046
+ } else if (m.type === "animated_gif") {
1047
+ videos.push(parseGif(m));
1040
1048
  }
1041
1049
  const sensitive = m.ext_sensitive_media_warning;
1042
1050
  if (sensitive != null) {
@@ -1045,6 +1053,19 @@ function parseMediaGroups(media) {
1045
1053
  }
1046
1054
  return { sensitiveContent, photos, videos };
1047
1055
  }
1056
+ function parseGif(m) {
1057
+ const gif = {
1058
+ id: m.id_str,
1059
+ preview: m.media_url_https
1060
+ };
1061
+ const variants = m.video_info?.variants ?? [];
1062
+ const url = variants.find((v) => v.content_type === "video/mp4")?.url;
1063
+ if (url) {
1064
+ gif.preview = url;
1065
+ gif.url = url;
1066
+ }
1067
+ return gif;
1068
+ }
1048
1069
  function parseVideo(m) {
1049
1070
  const video = {
1050
1071
  id: m.id_str,