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