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

Working but got caught in expected syntax of DICT for streams #1

Closed
clintm99 opened this issue Dec 6, 2021 · 4 comments
Closed

Working but got caught in expected syntax of DICT for streams #1

clintm99 opened this issue Dec 6, 2021 · 4 comments

Comments

@clintm99
Copy link

clintm99 commented Dec 6, 2021

I got as far as cr.get_episodes(season_id)
and now I need to get the streams and formats, but I'm stuck on expected syntax for get_streams.
My example output from get_episodes()
cr.get_episodes(season_id)
was
...
'links': {'episode/channel': {'href': '/cms/v2/US/M3/crunchyroll/channels/crunchyroll'}, 'episode/season': {'href': '/cms/v2/US/M3/crunchyroll/seasons/GY1X4ZQ2Y'},
'episode/series': {'href': '/cms/v2/US/M3/crunchyroll/series/GR4PVDGEY'}, 'streams': {'href': '/cms/v2/US/M3/crunchyroll/videos/GM8FXDG8M/streams'}}
..
but expected DICT format was unknown with error when I try various ways of inputting what is expected:
line 98 in get_streams
episode["links"]["stream"]["href"]

Can you give me example expected syntax for get_streams and get_format based on get_epidode() output?

Glad someone is doing the work with CR beta.
Thanks!

@stefanodvx
Copy link
Owner

@clintm99 can you give me code and output? anyway, pass one item of episodes in get_streams() to get streams

@clintm99
Copy link
Author

clintm99 commented Dec 6, 2021

Hi, Thanks.

cr.get_seasons("GR4PVDGEY")
[{'class': 'season', 'href': '/cms/v2/US/M3/crunchyroll/seasons/GY1X4ZQ2Y', 'resource_key': 'cms:/seasons/GY1X4ZQ2Y', 'links': {'season/channel': {'href': '/cms/v2/US/M3/crunchyroll/channels/crunchyroll'}, 'season/episodes': {'href': '/cms/v2/US/M3/crunchyroll/episodes?season_id=GY1X4ZQ2Y'}, 'season/series': {'href': '/cms/v2/US/M3/crunchyroll/series/GR4PVDGEY'}}, 'actions': {}, 'id': 'GY1X4ZQ2Y', 'channel_id': 'crunchyroll', 'title': 'Full Metal Panic! Invisible Victory', 'slug_title': 'full-metal-panic-invisible-victory', 'series_id': 'GR4PVDGEY', 'season_number': 1, 'is_complete': False, 'description': '', 'keywords': [], 'season_tags': ['Primavera-2018'], 'images': {}, 'is_mature': False, 'mature_blocked': False, 'is_subbed': True, 'is_dubbed': False, 'is_simulcast': False, 'seo_title': '', 'seo_description': '', 'availability_notes': ''}]

cr.get_episodes("GY1X4ZQ2Y")
...
{'class': 'episode', 'href': '/cms/v2/US/M3/crunchyroll/episodes/GR4P9498Y', 'resource_key': 'cms:/episodes/GR4P9498Y', 'links': {'episode/channel': {'href': '/cms/v2/US/M3/crunchyroll/channels/crunchyroll'}, 'episode/season': {'href': '/cms/v2/US/M3/crunchyroll/seasons/GY1X4ZQ2Y'}, 'episode/series': {'href': '/cms/v2/US/M3/crunchyroll/series/GR4PVDGEY'}, 'streams': {'href': '/cms/v2/US/M3/crunchyroll/videos/GM8FXDG8M/streams'}}, 'actions': {}, 'id': 'GR4P9498Y', 'channel_id': 'crunchyroll', 'series_id': 'GR4PVDGEY', 'series_title': 'Full Metal Panic! Invisible Victory', 'series_slug_title': 'full-metal-panic-invisible-victory', 'season_id': 'GY1X4ZQ2Y', 'season_title': 'Full Metal Panic! Invisible Victory', 'season_slug_title': 'full-metal-panic-invisible-victory', 'season_number': 1, 'episode': '12', 'episode_number': 12, 'sequence_number': 12, 'production_episode_id': '', 'title': 'Make My Day', 'slug_title': 'make-my-day', 'description': '', 'hd_flag': True, 'is_mature': False, 'mature_blocked': False, 'episode_air_date': '2018-07-18T20:30:00+09:00', 'is_subbed': True, 'is_dubbed': False, 'is_clip': False, 'seo_title': '', 'seo_description': '', 'season_tags': ['Primavera-2018'], 'available_offline': True, 'media_type': 'episode', 'slug': '', 'images': {'thumbnail': [[{'width': 320, 'height': 180, 'type': 'thumbnail', 'source': 'https://beta.crunchyroll.com/imgsrv/display/thumbnail/320x180/catalog/crunchyroll/0e7a0ed31c2810a8efc07e45e47124ca.jpeg'}, {'width': 600, 'height': 338, 'type': 'thumbnail', 'source': 'https://beta.crunchyroll.com/imgsrv/display/thumbnail/600x338/catalog/crunchyroll/0e7a0ed31c2810a8efc07e45e47124ca.jpeg'}, {'width': 640, 'height': 360, 'type': 'thumbnail', 'source': 'https://beta.crunchyroll.com/imgsrv/display/thumbnail/640x360/catalog/crunchyroll/0e7a0ed31c2810a8efc07e45e47124ca.jpeg'}, {'width': 800, 'height': 450, 'type': 'thumbnail', 'source': 'https://beta.crunchyroll.com/imgsrv/display/thumbnail/800x450/catalog/crunchyroll/0e7a0ed31c2810a8efc07e45e47124ca.jpeg'}, {'width': 1200, 'height': 675, 'type': 'thumbnail', 'source': 'https://beta.crunchyroll.com/imgsrv/display/thumbnail/1200x675/catalog/crunchyroll/0e7a0ed31c2810a8efc07e45e47124ca.jpeg'}, {'width': 1440, 'height': 810, 'type': 'thumbnail', 'source': 'https://beta.crunchyroll.com/imgsrv/display/thumbnail/1440x810/catalog/crunchyroll/0e7a0ed31c2810a8efc07e45e47124ca.jpeg'}, {'width': 1600, 'height': 900, 'type': 'thumbnail', 'source': 'https://beta.crunchyroll.com/imgsrv/display/thumbnail/1600x900/catalog/crunchyroll/0e7a0ed31c2810a8efc07e45e47124ca.jpeg'}, {'width': 1920, 'height': 1080, 'type': 'thumbnail', 'source': 'https://beta.crunchyroll.com/imgsrv/display/thumbnail/1920x1080/catalog/crunchyroll/0e7a0ed31c2810a8efc07e45e47124ca.jpeg'}]]}, 'duration_ms': 1450099, 'is_premium_only': False, 'listing_id': '', 'subtitle_locales': ['en-US'], 'playback': 'https://pl.crunchyroll.com/asset/13b7d1a06139c49047fcb52d212368cb/v/b3c91d51a44aca33d1ab393a2b0ec83c/languages/en-US?*&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cCo6Ly9wbC5jcnVuY2h5cm9sbC5jb20vYXNzZXQvMTNiN2QxYTA2MTM5YzQ5MDQ3ZmNiNTJkMjEyMzY4Y2Ivdi9iM2M5MWQ1MWE0NGFjYTMzZDFhYjM5M2EyYjBlYzgzYy8~KiIsIkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTYzODk0ODEyNX19fV19&Signature=Ac33o63Q-3KRoIJPSS7nshCoIULBNJq0KctpAfj6ciwh9wCXZ0OS5JEbJKsSzj4qLfl775P5yrI4hLDVU8jVpPVzeuh1oEncfJIzM3-WdrCbxTfhacjo~A4nd8KOPcHO0uLcyLJWQujGmt09IaEtL-l6gyo71-6I1z7J8lWOc0~IipQRaMgn2-D3-Iwm3re~tC69aTvANJ0D0TlCd92SNaIoYuUJI4IQqIBVEykdpP6fuw1I6AGXXqE4-oUlGDjDY9oEGEGpdpmOnLb5zRsgRvdLQU8m~aVWneQo3Sd9yE8njR3BXhcBFqI19EjTcb8ffZNmaS9EicIJvZ3lJKCqYg__&Key-Pair-Id=APKAJMWSQ5S7ZB3MF5VA', 'availability_notes': ''}]
...

Figured out I needed to put the whole class in there. Passed output to var object stream

stream = cr.get_streams( {'class': 'episode', 'href': '/cms/v2/US/M3/crunchyroll/episodes/GR4P9498Y', 'resource_key': 'cms:/episodes/GR4P9498Y', 'links': {'episode/channel': {'href': '/cms/v2/US/M3/crunchyroll/channels/crunchyroll'}, 'episode/season': {'href': '/cms/v2/US/M3/crunchyroll/seasons/GY1X4ZQ2Y'}, 'episode/series': {'href': '/cms/v2/US/M3/crunchyroll/series/GR4PVDGEY'}, 'streams': {'href': '/cms/v2/US/M3/crunchyroll/videos/GM8FXDG8M/streams'}}, 'actions': {}, 'id': 'GR4P9498Y', 'channel_id': 'crunchyroll', 'series_id': 'GR4PVDGEY', 'series_title': 'Full Metal Panic! Invisible Victory', 'series_slug_title': 'full-metal-panic-invisible-victory', 'season_id': 'GY1X4ZQ2Y', 'season_title': 'Full Metal Panic! Invisible Victory', 'season_slug_title': 'full-metal-panic-invisible-victory', 'season_number': 1, 'episode': '12', 'episode_number': 12, 'sequence_number': 12, 'production_episode_id': '', 'title': 'Make My Day', 'slug_title': 'make-my-day', 'description': '', 'hd_flag': True, 'is_mature': False, 'mature_blocked': False, 'episode_air_date': '2018-07-18T20:30:00+09:00', 'is_subbed': True, 'is_dubbed': False, 'is_clip': False, 'seo_title': '', 'seo_description': '', 'season_tags': ['Primavera-2018'], 'available_offline': True, 'media_type': 'episode', 'slug': '', 'images': {'thumbnail': [[{'width': 320, 'height': 180, 'type': 'thumbnail', 'source': 'https://beta.crunchyroll.com/imgsrv/display/thumbnail/320x180/catalog/crunchyroll/0e7a0ed31c2810a8efc07e45e47124ca.jpeg'}, {'width': 600, 'height': 338, 'type': 'thumbnail', 'source': 'https://beta.crunchyroll.com/imgsrv/display/thumbnail/600x338/catalog/crunchyroll/0e7a0ed31c2810a8efc07e45e47124ca.jpeg'}, {'width': 640, 'height': 360, 'type': 'thumbnail', 'source': 'https://beta.crunchyroll.com/imgsrv/display/thumbnail/640x360/catalog/crunchyroll/0e7a0ed31c2810a8efc07e45e47124ca.jpeg'}, {'width': 800, 'height': 450, 'type': 'thumbnail', 'source': 'https://beta.crunchyroll.com/imgsrv/display/thumbnail/800x450/catalog/crunchyroll/0e7a0ed31c2810a8efc07e45e47124ca.jpeg'}, {'width': 1200, 'height': 675, 'type': 'thumbnail', 'source': 'https://beta.crunchyroll.com/imgsrv/display/thumbnail/1200x675/catalog/crunchyroll/0e7a0ed31c2810a8efc07e45e47124ca.jpeg'}, {'width': 1440, 'height': 810, 'type': 'thumbnail', 'source': 'https://beta.crunchyroll.com/imgsrv/display/thumbnail/1440x810/catalog/crunchyroll/0e7a0ed31c2810a8efc07e45e47124ca.jpeg'}, {'width': 1600, 'height': 900, 'type': 'thumbnail', 'source': 'https://beta.crunchyroll.com/imgsrv/display/thumbnail/1600x900/catalog/crunchyroll/0e7a0ed31c2810a8efc07e45e47124ca.jpeg'}, {'width': 1920, 'height': 1080, 'type': 'thumbnail', 'source': 'https://beta.crunchyroll.com/imgsrv/display/thumbnail/1920x1080/catalog/crunchyroll/0e7a0ed31c2810a8efc07e45e47124ca.jpeg'}]]}, 'duration_ms': 1450099, 'is_premium_only': False, 'listing_id': '', 'subtitle_locales': ['en-US'], 'playback': 'https://pl.crunchyroll.com/asset/13b7d1a06139c49047fcb52d212368cb/v/b3c91d51a44aca33d1ab393a2b0ec83c/languages/en-US?*&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cCo6Ly9wbC5jcnVuY2h5cm9sbC5jb20vYXNzZXQvMTNiN2QxYTA2MTM5YzQ5MDQ3ZmNiNTJkMjEyMzY4Y2Ivdi9iM2M5MWQ1MWE0NGFjYTMzZDFhYjM5M2EyYjBlYzgzYy8~KiIsIkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTYzODk0ODEyNX19fV19&Signature=Ac33o63Q-3KRoIJPSS7nshCoIULBNJq0KctpAfj6ciwh9wCXZ0OS5JEbJKsSzj4qLfl775P5yrI4hLDVU8jVpPVzeuh1oEncfJIzM3-WdrCbxTfhacjo~A4nd8KOPcHO0uLcyLJWQujGmt09IaEtL-l6gyo71-6I1z7J8lWOc0~IipQRaMgn2-D3-Iwm3re~tC69aTvANJ0D0TlCd92SNaIoYuUJI4IQqIBVEykdpP6fuw1I6AGXXqE4-oUlGDjDY9oEGEGpdpmOnLb5zRsgRvdLQU8m~aVWneQo3Sd9yE8njR3BXhcBFqI19EjTcb8ffZNmaS9EicIJvZ3lJKCqYg__&Key-Pair-Id=APKAJMWSQ5S7ZB3MF5VA', 'availability_notes': ''})

But now when I attempt to get formats, I get KeyError.

cr.get_formats(stream)
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.6/site-packages/crunchyroll_beta/init.py", line 116, in get_formats
video_url = streams["streams"]["adaptive_hls"][locale]["url"]
KeyError: 'it-IT'

Thank you 👍

@stefanodvx
Copy link
Owner

@clintm99 I updated the library, uninstall and reinstall and let me know what you think. problems should be fixed now.

@stefanodvx stefanodvx assigned stefanodvx and unassigned stefanodvx Dec 6, 2021
@clintm99
Copy link
Author

clintm99 commented Dec 6, 2021

Crispy and cleaner. Worked like a champ. Top notch.

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

2 participants