stefanodvx / crunpyroll Goto Github PK
View Code? Open in Web Editor NEWAsync API wrapper for Crunchyroll
License: MIT License
Async API wrapper for Crunchyroll
License: MIT License
I can not download music videos every time I put the code of any video of this type I get an error of 403 content not available.
I ask from ignorance, this may be because the method used to call Music from crunpyrrol is obsolete, since on the web appears for this type of links as musicvideo?
I leave the error code:
Traceback (most recent call last):
File "C:\Users\Lina\Desktop\Crunpyrrol\Programas\crunpyroll_cr(1080p).py", line 131, in <module>
asyncio.run(main())
File "C:\Python311\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\Lina\Desktop\Crunpyrrol\Programas\crunpyroll_cr(1080p).py", line 60, in main
streams = await client.get_streams(episode_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\crunpyroll\methods\get_streams.py", line 28, in get_streams
response = await self.api_request(
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\crunpyroll\client.py", line 119, in api_request
return Client.parse_response(response, method=method)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\crunpyroll\client.py", line 92, in parse_response
raise CrunpyrollException(message)
crunpyroll.errors.CrunpyrollException: [403] {"error":"Content Not Available"}
and the link to one of the videos that gives me the error:
https://www.crunchyroll.com/es-es/watch/musicvideo/MV7DB0A85A/synthetic-sympathy
Hi,
My December 2021 version works good, but the Feb 9th version gives me:
`Python 3.7.9 (default, Aug 19 2020, 17:05:11)
[GCC 9.3.1 20200408 (Red Hat 9.3.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
from crunchyroll_beta import Crunchyroll
Traceback (most recent call last):
File "", line 1, in
File "/tmp/crunchyroll-main/crunchyroll_beta/init.py", line 1, in
from .api import Crunchyroll
File "/tmp/crunchyroll-main/crunchyroll_beta/api.py", line 124
if expiration := self.account_data.expires:
^
SyntaxError: invalid syntax
where api.py is.
11488 2ๆ 9 11:59 crunchyroll_beta/api.py`
Thanks :)
File "/usr/local/lib/python3.7/dist-packages/crunchyroll_beta/api.py", line 124
if expiration := self.account_data.expires:
^
SyntaxError: invalid syntax
Hi!
I'm using Python 3.11 on Windows 11 and get the error:
SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1006)
I have tried installing certifi and run with the command: os.environ['SSL_CERT_FILE'] = certifi.where()
But I still get the same error.
As I know, there is no ssl error in the general Python environment as I can pull websites using the requests library. So the SSL error is specific to this library. Is there a way to disable SSL verification within the library or an alternative by any chance?
I tried disabling using ssl._create_default_https_context = ssl._create_unverified_context
too, but no luck.
Thank you
Does anyone know how to close the sessions?
After several downloads, Crunchyroll crashes...
The first one is that my programming knowledge is scarce, I can defend myself a little bit.
Is there any way to delete the open session after finishing the process, if so how exactly would the code, because every time I download something, that is if I go down 3 times to go to my control panel and see the sessions that are connected, I see a session generated by chrunpyroll, so far so good, and it touches manually delete it, but as I said if I have downloaded 3 times to remove it reappears again the same number of times I downloaded.
I do not know, if the instruction to eliminate the session is by means of the command that appears in the instructions of the beginning cdm.close(session_id) or if this is for another thing, if it is thus then it is not working for me.
In the previous version there was the "browse" method. This allowed me to create a list of all series. Would it be possible to get such a method again?
When you request more than 20 streams in CR they blocked temporally the account because right no crunpyroll is not closing streaming after requested, so you need to implement this function (@inks007): smirgol/plugin.video.crunchyroll@23ade04
I tried to do it with this method:
from crunpyroll import enums
from crunpyroll import types
import requests
import crunpyroll
class ClearActiveStream:
async def clear_active_stream(self: "crunpyroll.Client", episode_id: str, token: str):
if not episode_id or not token:
return
try:
await self.session.retrieve()
response = await self.api_request(
method="DELETE",
endpoint=f"v1/token/{episode_id}/{token}",
host=enums.APIHost.PLAY_SERVICE
)
except requests.exceptions.RequestException as e:
# catch timeout or any other possible exception
print(e)
return
and then on client.py this change:
@staticmethod
def parse_response(response: httpx.Response) -> Optional[Union[Dict, str]]:
status_code = response.status_code
text_content = response.text
message = f"[{status_code}] {text_content}"
try:
content = response.json()
except json.JSONDecodeError:
content = response.text
if status_code != 200:
if status_code == 204:
return content
raise CrunpyrollException(message)
return content
It is possible that there is a better solution, perhaps you who have more experience modifying crunpyroll know how to improve it.
Hello,
With the normal API, there is a possibility to delete the devices registered on our account. This can come in handy as they become numerous over time (DEVICE_ID is generated instead of being fixed, which adds a new device each time a program using Crunpyroll is launched and we are limited to 20 devices per account). Is it possible to implement the corresponding endpoint (https://www.crunchyroll.com/accounts/v1/i_think_account_id_goes_here_or_something_like_"me"/devices/deactivate)?
And is there something similar on the PLAY_HOST? Apparently, deleting all devices from my account is not enough to disable all open streams on the PLAY_HOST, which leads to an API error with get_streams (420 too_many_queued_streams, useStreamLimits: true in the error message).
I get this error:
crunpyroll.errors.CrunpyrollException: [401] {"code":"auth.obtain_access_token.client_inactive","context":[],"error":"invalid_client"}
I guess you need to update public token and user agent version.
the session seems to expire after 5 minutes
I tried to do a test by adding a 6 minute sleep to the code provided as an example
code:
async def main():
# Start client and login
await client.start()
await asyncio.sleep(360)
# Search for Attack on Titan
query = await client.search("Attack On Titan")
series_id = query.items[0].id
print(series_id)
# Retrieve all seasons of the series
seasons = await client.get_seasons(series_id)
print(seasons)
asyncio.run(main())
output:
Traceback (most recent call last):
File "/root/test.py", line 25, in
asyncio.run(main())
File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/root/test.py", line 18, in main
query = await client.search("Attack On Titan")
File "/root/crunpyroll/methods/search.py", line 42, in search
await self.session.retrieve()
File "/root/crunpyroll/session.py", line 41, in retrieve
await self.refresh()
File "/root/crunpyroll/session.py", line 69, in refresh
response = await self._client.api_request(
File "/root/crunpyroll/client.py", line 89, in api_request
return Client.parse_response(response)
File "/root/crunpyroll/client.py", line 62, in parse_response
raise CrunpyrollException(message)
crunpyroll.errors.CrunpyrollException: [401] {"code":"auth.obtain_access_token.missing_client_credential","context":[{"code":"auth.obtain_access_token.missing_client_credentials","field":"Authorization"}],"error":"invalid_client"}
I tried adding a print to "{self.expiration}" in the "authorize" function in the "session.py" file to see the expiration of the session at the time of authentication and apparently the session always lasts 5 minutes
With the Crunchyroll beta, some movies consist of a single video and do not appear to have seasons or episodes that the API can handle. For example:
GRK5Z4P96
(Black Jack the Movie)
GRWE20Z3R
(Cardcaptor Sakura the Movie)
Attempting to call get_series()
or get_seasons()
with one of these IDs returns this error:
crunchyroll_beta.errors.CrunchyrollError: [404] Error occured: Invalid series identifier
Calling get_episodes()
on the ID returns an empty list. It's not clear how to get from a series ID to an episode ID. It might make sense for the module to generate a dummy season and episode listing just for consistency.
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in
start(fakepyfile,mainpyfile)
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
exec(open(mainpyfile).read(), main.dict)
File "", line 1, in
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.11/site-packages/crunpyroll/init.py", line 1, in
from .client import Client
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.11/site-packages/crunpyroll/client.py", line 1, in
from .methods import Methods
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.11/site-packages/crunpyroll/methods/init.py", line 11, in
from .get_old_streams import GetOldStreams
ModuleNotFoundError: No module named 'crunpyroll.methods.get_old_streams'
Apparently they have updated something in crunchy that can't be downloaded anymore, I get this error
Traceback (most recent call last):
File "C:\Users\Lina\Desktop\Crunchyrill\Programas\crunpyroll_cr(720p).py", line 132, in <module>
asyncio.run(main())
File "C:\Python311\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\Lina\Desktop\Crunchyrill\Programas\crunpyroll_cr(720p).py", line 53, in main
await client.start()
File "C:\Python311\Lib\site-packages\crunpyroll\client.py", line 73, in start
return await self.session.authorize()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\crunpyroll\session.py", line 41, in authorize
response = await self._client.api_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\crunpyroll\client.py", line 119, in api_request
return Client.parse_response(response, method=method)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\crunpyroll\client.py", line 92, in parse_response
raise CrunpyrollException(message)
crunpyroll.errors.CrunpyrollException: [401] {"code":"auth.obtain_access_token.client_inactive","context":[],"error":"invalid_client"}
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!
Could someone could give me a hand to get the name of the series and the number of the specific episode when you enter the episode code ie GVWU07MPE, the script has been passed to me and I do not have much idea of python programming and I have been able to modify it to my needs as best I could, asking you by keyboard to enter the episode code and inserting it, but as much as I look at the document with the info crunpyrol I do not clarify how I should make calls to get that information.
That is to say that when I enter "GVWU07MPE" it should show me this Wind Breaker - 01
episoide_id = input("Insert episode code: ")
async def main():
await client.start()
index = await client.get_index()
# Get streams of the episode/movie
streams = await client.get_streams(episode_id)
# Get manifest of the format you prefer
manifest = await client.get_manifest(streams.url)
access_token = client.session.access_token
print(access_token)
.
.
.
asyncio.run(main())
The API function for get_old_streams
now returns a 403. The yt-dlp project recently reported that Crunchyroll has closed the last non-DRM endpoint, so that might have something to do with it.
Great tool , but can i have a simple direction of getting file
l3cdm.wvd ?
so i can test DeDRM, thanks, any help will be appreciated!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.