Source code for instagram_private_api.endpoints.common

class ClientDeprecationWarning(DeprecationWarning):

class ClientPendingDeprecationWarning(PendingDeprecationWarning):

class ClientExperimentalWarning(UserWarning):

[docs]class MediaTypes(object): """Psuedo enum-ish/lookup class for media types.""" PHOTO = 1 #: Photo type VIDEO = 2 #: Video type CAROUSEL = 8 #: Carousel/Album type ALL = (PHOTO, VIDEO, CAROUSEL) __media_type_map = { 'image': PHOTO, 'video': VIDEO, 'carousel': CAROUSEL, }
[docs] @staticmethod def id_to_name(media_type_id): """Convert a media type ID to its name""" try: return [k for k, v in MediaTypes.__media_type_map.items() if v == media_type_id][0] except IndexError: raise ValueError('Invalid media ID')
[docs] @staticmethod def name_to_id(media_type_name): """Convert a media type name to its ID""" try: return MediaTypes.__media_type_map[media_type_name] except KeyError: raise ValueError('Invalid media name')