diff --git a/instagrapi/mixins/media.py b/instagrapi/mixins/media.py index 9b3c7192..dc4cbe9b 100644 --- a/instagrapi/mixins/media.py +++ b/instagrapi/mixins/media.py @@ -123,7 +123,7 @@ def media_pk_from_code(self, code: str) -> str: B-fKL9qpeab -> 2278584739065882267 CCQQsCXjOaBfS3I2PpqsNkxElV9DXj61vzo5xs0 -> 2346448800803776129 """ - return InstagramIdCodec.decode(code[:11]) + return InstagramIdCodec.decode(code) def media_pk_from_url(self, url: str) -> str: """ diff --git a/instagrapi/utils.py b/instagrapi/utils.py index c4834108..f62dcd67 100644 --- a/instagrapi/utils.py +++ b/instagrapi/utils.py @@ -7,6 +7,7 @@ import urllib +# $$("meta[property^='al:ios:url']")[0].getAttribute("content").split("media?id=")[1] class InstagramIdCodec: ENCODING_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" @@ -26,8 +27,9 @@ def encode(num, alphabet=ENCODING_CHARS): return "".join(arr) @staticmethod - def decode(shortcode, alphabet=ENCODING_CHARS): - """Covert a shortcode to a numeric value.""" + def decode(code, alphabet=ENCODING_CHARS): + """Covert a code to a numeric value.""" + shortcode = code[:11] if code[0] != "-" and code[0] != "_" else code[:10] base = len(alphabet) strlen = len(shortcode) num = 0