Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some rudimentary tooling to deal with provider ids #482

Open
sevenrats opened this issue Feb 11, 2024 · 1 comment
Open

some rudimentary tooling to deal with provider ids #482

sevenrats opened this issue Feb 11, 2024 · 1 comment

Comments

@sevenrats
Copy link
Member

sevenrats commented Feb 11, 2024

# these funcs are rudimentary tooling to assist you in dealing with tmdb provider ids.
# there are thousands of ids provided by the https://api.themoviedb.org/3/watch/providers/{type}
# endpoint and they are not organized in a way that is logically useful.  This script should not
# be included in your program, but used to help you make your enums. This script allows you
# to define two logical types of providers. Logical platform providers such as Netflix and Amazon,
# which host streaming platforms, may or may not produce content, and may or may not be a logical
# content seller. A content seller is any provider which allows content they produce to be
# provided by a platform provider other than their own, if they have one.
# Arranging the data this way allows us to cover three main use cases.
# 1) All provider ids that represent all content on all platform (includeChannels = True)
# 2) All provider ids that represent all content on all platforms EXCEPT addon channels. (includeChannels = False)
# 3) All provider ids that represent all content by all creators.
# Getting this far should allow you to get any id groups you want quickly with list comprehensions.
# createIdToNameMap function reverses the outputs of the getProviders* functions to easily
# lookup a particular id

# Some notable errata not handled by this code:
# 1) Netflix Kids (175) is included in the Netflix group
# 2) At least Crave Starz and perhaps other Crave channels do not contain the string "channel"
# 3) "Watchbox" (171) hits on "HBO." Remove it from the HBO group.

import httpx

apiKey = "abcdefg"

logicalContentSellers = [
    "HBO",
    "IFC",
    "MotorTrend",
    "Paramount",
    "Disney"
]

logicalPlatformProviders = [
        'Amazon',
        'Apple',
        'Disney',
        'Google',
        'HBO',
        'Hulu',
        'Microsoft',
        'Netflix',
        'Sky',
        'Spectrum',
        'Vudu',
        'YouTube',
        'Paramount'
    ]


def getProvidersByType(_type: str) ->  dict:
    _type = _type.lower()
    if _type not in ['tv','movie']:
        raise Exception("Function argument must be 'tv' or 'movie'")
    allTypeProvidersRequest = httpx.get(
        f"https://api.themoviedb.org/3/watch/providers/{_type}?language=en-US&api_key={apiKey}"
    )
    if allTypeProvidersRequest.status_code != 200:
        raise Exception("TMDB API Request Failed")
    allTypeProvidersRawJson = allTypeProvidersRequest.json()
    return {
        x['provider_name'].lower(): x['provider_id'] for x in sorted(
            allTypeProvidersRawJson['results'], key=lambda x: x['provider_id']
        )
    }

def getProvidersAll() -> dict:
    output = {}
    for _type in ["movie", "tv"]:
        output.update(getProvidersByType(_type))
    return dict(sorted(output.items(), key=lambda x: x[1]))

def createLogicalPlatformGroups(providers: dict, includeChannels: bool = False) -> dict:
    # this function takes the output from getProviders funcs as an argument
    # it will output a dict of {providers: [ids]}
    # if includeChannels is true, it will include ids of channels on each platform.
    output = {}
    for platform in logicalPlatformProviders:
        if includeChannels and platform not in logicalContentSellers:
            # don't show the channels of dual members
            output[platform] = [
                providers[x] for x in providers if platform.lower() in x.lower()
            ]
        else:
            output[platform] = [
                providers[x] for x in providers if platform.lower() in x.lower() and "channel" not in x.lower()
            ]
    return output


def createLogicalProviderGroups(providers: dict) -> dict:
    # this function takes the output from getProviders funcs as an argument
    # it will output a dict of {providers: [ids]}
    # this function is different because channels become grouped with their
    # content creator instead of their platforms.
    output = {}
    for platform in logicalPlatformProviders:
        output[platform] = [
                providers[x] for x in providers if platform.lower() in x.lower() and "channel" not in x.lower()
            ]
    for seller in logicalContentSellers:
        output[seller] = [
                providers[x] for x in providers if seller.lower() in x.lower()
            ]
    return output

def createIdToNameMap(providers: dict) -> dict:
    # this function takes the output from getProviders funcs as an argument
    # it will output a dict like {id: name for each provider in providers}
    # HINT: createIdToNameMap(getProvidersAll())
    output = {}
    for provider in providers:
        # we are just switching the keys and values of providers
        output[providers[provider]] = provider
    return output
@sevenrats
Copy link
Member Author

At the time of reporting this issue, this was the complete map of all providers:

{
    "apple tv": 2,
    "google play movies": 3,
    "vudu": 7,
    "netflix": 8,
    "amazon video": 10,
    "mubi": 11,
    "crackle": 12,
    "hulu": 15,
    "netmovies": 19,
    "maxdome store": 20,
    "stan": 21,
    "quickflix store": 24,
    "fandor": 25,
    "hbo now": 27,
    "netzkino": 28,
    "sky go": 29,
    "wow": 30,
    "alleskino": 33,
    "mgm plus": 34,
    "rakuten tv": 35,
    "showtime": 37,
    "bbc iplayer": 38,
    "now tv": 39,
    "chili": 40,
    "itvx": 41,
    "starz": 43,
    "looke": 47,
    "volta": 53,
    "boxoffice": 54,
    "showmax": 55,
    "ocs go": 56,
    "canal vod": 58,
    "bbox vod": 59,
    "orange vod": 61,
    "atres player": 62,
    "filmin": 63,
    "filmin plus": 64,
    "filmin latino": 66,
    "microsoft store": 68,
    "path\u00e9 thuis": 71,
    "videoland": 72,
    "tubi tv": 73,
    "viaplay": 76,
    "cbs": 78,
    "nbc": 79,
    "amc": 80,
    "tenplay": 82,
    "the cw": 83,
    "u-next": 84,
    "dtv": 85,
    "acorn tv": 87,
    "naver store": 96,
    "watcha": 97,
    "shudder": 99,
    "guidedoc": 100,
    "channel 4": 103,
    "timvision": 109,
    "infinity+": 110,
    "ivi": 113,
    "okko": 115,
    "amediateka": 116,
    "kinopoisk": 117,
    "hbo": 118,
    "amazon prime video": 119,
    "voot": 121,
    "hotstar": 122,
    "fxnow": 123,
    "bookmyshow": 124,
    "sky store": 130,
    "sbs on demand": 132,
    "videobuster": 133,
    "foxtel now": 134,
    "abc iview": 135,
    "uktv play": 137,
    "filmo": 138,
    "cineplex": 140,
    "sundance now": 143,
    "icitoutv": 146,
    "sixplay": 147,
    "abc": 148,
    "movistar plus": 149,
    "blue tv": 150,
    "history": 155,
    "a&e": 156,
    "lifetime": 157,
    "viu": 158,
    "catchplay": 159,
    "iflix": 160,
    "hollystar": 164,
    "claro video": 167,
    "watchbox": 171,
    "netflix kids": 175,
    "pantaflix": 177,
    "magentatv": 178,
    "hollywood suite": 182,
    "universal pictures": 184,
    "screambox": 185,
    "youtube premium": 188,
    "curzon home cinema": 189,
    "curiosity stream": 190,
    "kanopy": 191,
    "youtube": 192,
    "sfr play": 193,
    "starz play amazon channel": 194,
    "animax plus amazon channel": 195,
    "acorntv amazon channel": 196,
    "britbox amazon channel": 197,
    "fandor amazon channel": 199,
    "mubi amazon channel": 201,
    "screambox amazon channel": 202,
    "showtime amazon channel": 203,
    "shudder amazon channel": 204,
    "sundance now amazon channel": 205,
    "cw seed": 206,
    "the roku channel": 207,
    "pbs": 209,
    "sky": 210,
    "freeform": 211,
    "hoopla": 212,
    "eros now": 218,
    "ard mediathek": 219,
    "jio cinema": 220,
    "rai play": 222,
    "hayu": 223,
    "bfi player": 224,
    "telecine play": 227,
    "crave": 230,
    "zee5": 232,
    "arte": 234,
    "youtube free": 235,
    "france tv": 236,
    "sony liv": 237,
    "universcine": 239,
    "popcornflix": 241,
    "meo": 242,
    "comedy central": 243,
    "vod poland": 245,
    "7plus": 246,
    "boomerang": 248,
    "horizon": 250,
    "urban movie channel": 251,
    "yupp tv": 255,
    "fubotv": 257,
    "criterion channel": 258,
    "magnolia selects": 259,
    "wwe network": 260,
    "noggin amazon channel": 262,
    "dreamworkstv amazon channel": 263,
    "myoutdoortv": 264,
    "history vault": 268,
    "funimation now": 269,
    "neon tv": 273,
    "qubittv": 274,
    "laugh out loud": 275,
    "smithsonian channel": 276,
    "pure flix": 278,
    "redbox": 279,
    "crunchyroll": 283,
    "lifetime movie club": 284,
    "bbc player amazon channel": 285,
    "zdf herzkino amazon channel": 286,
    "bfi player amazon channel": 287,
    "boomerang amazon channel": 288,
    "cinemax amazon channel": 289,
    "hallmark movies now amazon channel": 290,
    "mz choice amazon channel": 291,
    "pbs kids amazon channel": 293,
    "pbs masterpiece amazon channel": 294,
    "viewster amazon channel": 295,
    "hayu amazon channel": 296,
    "ziggo tv": 297,
    "rtl+": 298,
    "pluto tv": 300,
    "joyn": 304,
    "crave starz": 305,
    "globoplay": 307,
    "o2 tv": 308,
    "sun nxt": 309,
    "lacinetek": 310,
    "be tv go": 311,
    "vrt max": 312,
    "yelo play": 313,
    "cbc gem": 314,
    "hoichoi": 315,
    "adult swim": 318,
    "alt balaji": 319,
    "sky x": 321,
    "usa network": 322,
    "yle areena": 323,
    "cinemas a la demande": 324,
    "ctv": 326,
    "fox": 328,
    "flixfling": 331,
    "vudu free": 332,
    "my5": 333,
    "filmtastic amazon channel": 334,
    "disney plus": 337,
    "ruutu": 338,
    "movistartv": 339,
    "blutv": 341,
    "puhutv": 342,
    "bet+ amazon channel": 343,
    "rakuten viki": 344,
    "canal+ s\u00e9ries": 345,
    "fxnow canada": 348,
    "kino on demand": 349,
    "apple tv plus": 350,
    "amc on demand": 352,
    "darkmatter tv": 355,
    "wavve": 356,
    "docplay": 357,
    "directv": 358,
    "mediaset infinity": 359,
    "npo start": 360,
    "tcm": 361,
    "tnt": 363,
    "bravo tv": 365,
    "food network": 366,
    "indieflix": 368,
    "vod club": 370,
    "go3": 373,
    "9now": 378,
    "britbox": 380,
    "canal+": 381,
    "tv 2": 383,
    "hbo max": 384,
    "binge": 385,
    "peacock": 386,
    "peacock premium": 387,
    "sooner": 389,
    "wedotv": 392,
    "flixol\u00e9": 393,
    "tvnz": 395,
    "film1": 396,
    "bbc america": 397,
    "ahctv": 398,
    "animal planet": 399,
    "cooking channel": 400,
    "destination america": 402,
    "discovery": 403,
    "discovery life": 404,
    "diy network": 405,
    "hgtv": 406,
    "investigation discovery": 408,
    "motor trend": 410,
    "science channel": 411,
    "tlc": 412,
    "travel channel": 413,
    "vvvvid": 414,
    "anime digital networks": 415,
    "here tv": 417,
    "paramount network": 418,
    "tv land": 419,
    "logo tv": 420,
    "joyn plus": 421,
    "vh1": 422,
    "blockbuster": 423,
    "hbo go": 425,
    "sf anytime": 426,
    "mhz choice": 427,
    "contv": 428,
    "telstra tv": 429,
    "hidive": 430,
    "tv 2 play": 431,
    "flix premiere": 432,
    "ovid": 433,
    "ozflix": 434,
    "draken films": 435,
    "fetch tv": 436,
    "hungama play": 437,
    "chai flicks": 438,
    "shout! factory tv": 439,
    "threenow": 440,
    "nfb": 441,
    "nrk tv": 442,
    "filmstriben": 443,
    "dekkoo": 444,
    "classix": 445,
    "retrocrush": 446,
    "belas artes \u00e0 la carte": 447,
    "beamafilm": 448,
    "global tv": 449,
    "picl": 451,
    "rtpplay": 452,
    "mtv": 453,
    "topic": 454,
    "night flight plus": 455,
    "mitele ": 456,
    "vix ": 457,
    "vice tv ": 458,
    "rtbf": 461,
    "kirjastokino": 463,
    "kocowa": 464,
    "believe": 465,
    "bioskop online": 466,
    "directv go": 467,
    "genflix": 468,
    "club illico": 469,
    "filmrise": 471,
    "nlziet": 472,
    "revry": 473,
    "shemaroome": 474,
    "docsville": 475,
    "epic on": 476,
    "gospel play": 477,
    "history play": 478,
    "home of horror": 479,
    "filmtastic": 480,
    "arthousecnma": 481,
    "manoramamax": 482,
    "max stream": 483,
    "now": 484,
    "rooster teeth": 485,
    "spectrum on demand": 486,
    "oxygen": 487,
    "tvo": 488,
    "vidio": 489,
    "cine": 491,
    "illico": 492,
    "svt": 493,
    "cineasterna": 496,
    "tele2 play": 497,
    "south park": 498,
    "oldflix": 499,
    "wink": 501,
    "tata play": 502,
    "hi-yah": 503,
    "player": 505,
    "tbs": 506,
    "tru tv": 507,
    "disneynow": 508,
    "iwanttfc": 511,
    "tntgo": 512,
    "shadowz": 513,
    "asiancrush": 514,
    "mx player": 515,
    "noovo": 516,
    "triart play": 517,
    "spamflix": 521,
    "popcorntimes": 522,
    "discovery+": 524,
    "knowledge network": 525,
    "amc+": 526,
    "amc+ amazon channel": 528,
    "arrow": 529,
    "paramount plus": 531,
    "aha": 532,
    "amazon arthaus channel": 533,
    "argo": 534,
    "dogwoof on demand": 536,
    "zdf": 537,
    "plex": 538,
    "viddla": 539,
    "elisa viihde": 540,
    "rtve": 541,
    "filmfriend": 542,
    "contar": 543,
    "libreflix": 544,
    "spuul": 545,
    "wow presents plus": 546,
    "iffr unleashed": 548,
    "ipla": 549,
    "tenk": 550,
    "magellan tv": 551,
    "qft player": 552,
    "telia play": 553,
    "broadwayhd": 554,
    "the oprah winfrey network": 555,
    "tvzavr": 556,
    "more tv": 557,
    "cin\u00e9polis klic": 558,
    "filmzie": 559,
    "filmoteket": 560,
    "lionsgate play": 561,
    "moviesaints": 562,
    "kpn": 563,
    "filme filme": 566,
    "true story": 567,
    "docalliance films": 569,
    "premier": 570,
    "rtl play": 572,
    "kinopop": 573,
    "oi play": 574,
    "koreaondemand": 575,
    "klik film": 576,
    "tvigle": 577,
    "strim": 578,
    "nova play": 580,
    "iqiyi": 581,
    "paramount+ amazon channel": 582,
    "mgm plus amazon channel": 583,
    "discovery+ amazon channel": 584,
    "metrograph": 585,
    "ifc amazon channel": 587,
    "mgm amazon channel": 588,
    "teletoon+ amazon channel": 589,
    "now tv cinema": 591,
    "stv player": 593,
    "virgin tv go": 594,
    "eros now amazon channel": 595,
    "arrow video amazon channel": 596,
    "full moon amazon channel": 597,
    "itv amazon channel": 598,
    "pok\u00e9mon amazon channel": 599,
    "shout! factory amazon channel": 600,
    "motortrend amazon channel": 601,
    "filmbox live amazon channel": 602,
    "curiositystream amazon channel": 603,
    "docubay amazon channel": 604,
    "super channel amazon channel": 605,
    "stacktv amazon channel": 606,
    "outtv amazon channel": 607,
    "love nature amazon channel": 608,
    "smithsonian channel amazon channel": 609,
    "bbc earth amazon channel": 610,
    "the great courses signature collection amazon channel": 611,
    "umc amazon channel": 612,
    "freevee": 613,
    "vi movies and tv": 614,
    "w4free": 615,
    "hbo max free": 616,
    "paus": 618,
    "star plus": 619,
    "drtv": 620,
    "dansk filmskat": 621,
    "upc tv": 622,
    "wetv": 623,
    "kktv": 624,
    "line tv": 625,
    "otta": 626,
    "voyo": 627,
    "edisonline": 628,
    "osn": 629,
    "starzplay": 630,
    "hrti": 631,
    "showtime roku premium channel": 632,
    "paramount+ roku premium channel": 633,
    "starz roku premium channel": 634,
    "amc+ roku premium channel": 635,
    "mgm plus roku premium channel": 636,
    "pickbox now": 637,
    "public domain movies": 638,
    "cinemember": 639,
    "kino now": 640,
    "nexo plus": 641,
    "studiocanal presents apple tv channel": 642,
    "showtime apple tv channel": 675,
    "eventive": 677,
    "filmlegenden amazon channel": 678,
    "cinema of hearts amazon channel": 679,
    "bloody movies amazon channel": 680,
    "film total amazon channel": 681,
    "looke amazon channel": 683,
    "flixol\u00e9 amazon channel": 684,
    "ocs amazon channel ": 685,
    "home of horror amazon channel": 686,
    "arthouse cnma amazon channel": 687,
    "shortstv amazon channel": 688,
    "tvcortos amazon channel": 689,
    "pongalo amazon channel  ": 690,
    "play suisse": 691,
    "cultpix": 692,
    "turk on video amazon channel": 693,
    "serially": 696,
    "mejane": 697,
    "filmbox+": 701,
    "ibakatv": 702,
    "irokotv": 704,
    "hollywood suite amazon channel": 705,
    "moviedome plus amazon channel": 706,
    "aniverse amazon channel": 707,
    "superfresh amazon channel": 708,
    "comedy central plus amazon channel": 1706,
    "blutv amazon channel": 1707,
    "discovery amazon channel": 1708,
    "grjngo amazon channel": 1709,
    "historyplay amazon channel": 1710,
    "mtv plus amazon channel": 1711,
    "rtl passion amazon channel": 1712,
    "silverline amazon channel": 1713,
    "sony axn amazon channel": 1714,
    "shahid vip": 1715,
    "acontra plus": 1717,
    "ava vobb": 1722,
    "ava hbz": 1723,
    "ava csal": 1724,
    "ava bgb": 1725,
    "infinity selection amazon channel": 1726,
    "cg collection amazon channel": 1727,
    "iwonder full amazon channel": 1728,
    "full action amazon channel": 1729,
    "cine comico amazon channel": 1730,
    "universcine amazon channel": 1732,
    "action max amazon channel": 1733,
    "filmo amazon channel": 1734,
    "insomnia amazon channel": 1735,
    "shadowz amazon channel": 1736,
    "ina  madelen amazon channel": 1737,
    "benshi amazon channel": 1738,
    "pash amazon channel": 1739,
    "planet horror amazon channel": 1740,
    "dizi amazon channel": 1741,
    "acontra plus amazon channel": 1742,
    "historia y actualidad amazon channel": 1743,
    "icon film amazon channel": 1744,
    "curzon amazon channel": 1745,
    "hallmark tv amazon channel": 1746,
    "studiocanal presents amazon channel": 1747,
    "tod": 1750,
    "filmingo": 1756,
    "realeyz amazon channel": 1757,
    "bet+": 1759,
    "yorck on demand": 1764,
    "paramount+ with showtime": 1770,
    "takflix": 1771,
    "skyshowtime": 1773,
    "love and passion amazon channel": 1788,
    "lionsgate plus": 1790,
    "klassiki": 1793,
    "starz amazon channel": 1794,
    "netflix basic with ads": 1796,
    "studiocanal presents moviecult amazon channel": 1805,
    "studiocanal presents allstars amazon channel": 1806,
    "cohen media amazon channel": 1811,
    "max amazon channel": 1825,
    "behind the tree": 1829,
    "popflick": 1832,
    "tivify": 1838,
    "britbox apple tv channel ": 1852,
    "paramount plus apple tv channel ": 1853,
    "amc plus apple tv channel ": 1854,
    "starz apple tv channel": 1855,
    "magenta tv": 1856,
    "telenet": 1857,
    "univer video": 1860,
    "filmow": 1861,
    "uam tv": 1862,
    "pass warner amazon channel": 1870,
    "runtime": 1875,
    "brutx amazon channel": 1887,
    "animation digital network amazon channel": 1888,
    "universal+ amazon channel": 1889,
    "hopster amazon channel": 1890,
    "alleskino amazon channel": 1891,
    "rtl crime amazon channel": 1892,
    "crime+ investigation play amazon channel": 1893,
    "cineautore amazon channel": 1894,
    "anime generation amazon channel": 1895,
    "raro video amazon channel": 1896,
    "midnight factory amazon channel": 1897,
    "amazon minitv": 1898,
    "max": 1899,
    "ard plus": 1902,
    "tv+": 1904,
    "apollo": 1912,
    "reserva imovision": 1920,
    "kinobox": 1927,
    "prima plus": 1928,
    "filmtastic bei canal+": 1929,
    "lepsi tv": 1939,
    "tv4 play": 1944,
    "plex player": 1945,
    "reveel": 1948,
    "ovation tv": 1953,
    "angel studios": 1956,
    "cineverse": 1957,
    "ad tv": 1958,
    "midnight pulp": 1960,
    "allente": 1961,
    "fyi network": 1962,
    "xumo play": 1963,
    "national geographic": 1964,
    "molotov tv": 1967,
    "crunchyroll amazon channel": 1968,
    "distrotv": 1971,
    "myfilmfriend": 1972,
    "filmicca": 1973,
    "outside watch": 1976,
    "citytv": 1985,
    "npo plus": 1986,
    "brollie": 1988,
    "zdf select amazon channel ": 1989,
    "glewedtv": 1990,
    "videoload": 1993,
    "tele 5": 1994,
    "mtv katsomo": 2029,
    "toon goggles": 2030,
    "noggin apple tv channel": 2032,
    "a&e crime central apple tv channel": 2033,
    "acorn tv apple tv": 2034,
    "crime+investigation play apple tv channel": 2035,
    "allblk apple tv channel": 2036,
    "ard plus apple tv channel": 2037,
    "arthaus+ apple tv channel": 2038,
    "bbc select apple tv channel": 2039,
    "bet+  apple tv channel": 2040,
    "bfi player apple tv channel": 2041,
    "carnegie hall+ apple tv channel": 2042,
    "motortrend apple tv channel": 2043,
    "outtv apple tv channel": 2044,
    "up faith & family apple tv channel": 2045,
    "topic apple tv channel": 2046,
    "tastemade apple tv channel": 2047,
    "sundance now apple tv channel": 2048,
    "shudder apple tv channel": 2049,
    "screenpix apple tv channel": 2050,
    "mgm apple tv channel": 2051,
    "love nature apple tv channel": 2052,
    "lionsgate play apple tv channel": 2053,
    "lifetime play apple tv channel": 2054,
    "lifetime movie club apple tv channel": 2055,
    "ifc films unlimited apple tv channel": 2056,
    "history vault apple tv channel": 2057,
    "hallmark movies now apple tv channel": 2058,
    "eros now select apple tv channel": 2059,
    "curiositystream apple tv channel": 2060,
    "cinemax apple tv channel": 2061,
    "carnegie hall+ amazon channel": 2071,
    "history vault amazon channel": 2073,
    "lionsgate play amazon channel": 2074,
    "lifetime play amazon channel": 2075
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant