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