Add Media.url
authorHarmon <Harmon758@gmail.com>
Sat, 1 Jan 2022 14:35:17 +0000 (08:35 -0600)
committerHarmon <Harmon758@gmail.com>
Sat, 1 Jan 2022 14:35:17 +0000 (08:35 -0600)
Resolves #1722

tweepy/media.py

index aec6435b533d3ee3ccda9a1e36e6f5aa04549419..6e49b101a7ac65cf4151fdc7c56bdcc80dc158a5 100644 (file)
@@ -10,7 +10,7 @@ class Media(DataMapping):
     __slots__ = (
         "data", "media_key", "type", "duration_ms", "height",
         "non_public_metrics", "organic_metrics", "preview_image_url",
-        "promoted_metrics", "public_metrics", "width", "alt_text"
+        "promoted_metrics", "public_metrics", "width", "alt_text", "url"
     )
 
     def __init__(self, data):
@@ -28,6 +28,9 @@ class Media(DataMapping):
         self.width = data.get("width")
         self.alt_text = data.get("alt_text")
 
+        # https://twittercommunity.com/t/documentation-for-media-object-missing-url-field/163062
+        self.url = data.get("url")
+
     def __eq__(self, other):
         if isinstance(other, self.__class__):
             return self.media_key == other.media_key