Xonshiz / anime-dl

Anime-dl is a command-line program to download anime from CrunchyRoll and Funimation.
MIT License
229 stars 37 forks source link

Cannot use a string pattern on a bytes-like object #97

Open voyager-nx24 opened 5 years ago

voyager-nx24 commented 5 years ago

Command Line Arguments You Gave: main.py -i "https://www.crunchyroll.com/isekai-quartet/episode-1-come-together-quartet-783515" -u "xxx" -p "xxx"

Verbose Log Link: https://pastebin.com/YeR1evk2

Long Explanation: I first encountered this issue using Python 3.7.3. Thinking it might be related to #27 so I installed Python 3.5.4 but it still shows the same error. The verbose error log is from 3.5.4. Windows binary hasn't been updated to address the "cannot extract language error" that was fixed in master.

axipher commented 5 years ago

The Verbose Log doesn't show the error you got, for any of us to troubleshoot the code, we would need potentially your Console Output that hopefully would show which line of the python code it's failing on.

Otherwise, @Nicnl latest build of the offline EXE can be found here with most of the fixes thus far (I think this was the latest one he posted): https://github.com/Xonshiz/anime-dl/issues/86#issuecomment-476760004

voyager-nx24 commented 5 years ago

The console output is just these four lines,

Trying to login... Logged in successfully... Seems like this video isn't available... cannot use a string pattern on a bytes-like object

Thanks for the link to the EXE. The binary build does work on my end.

axipher commented 5 years ago

Hmm, odd, sorry I can't help more, but at least the updated EXE works for you.

Nicnl commented 5 years ago

Hey

The packaged exe works because it's not running Python 3 but Python 2
I don't remember which version exactly, I think it's 2.7? Will check once I'm home from work

When I started fixing the Crunchy issues, I myself tried to run it under Python 3, but I encountered the same problems

I'm not sure why the project was written in Python 2 in the first place, but well
It's just the way it is

Abu3safeer commented 5 years ago

looks like the different between those two version is big. I am a PHP programmer, and I don't remember having such big issues when using old script on new PHP versions.

Abu3safeer commented 5 years ago

There is an issue with an anime called saki https://www.crunchyroll.com/saki

the first season is 1920x1072 not 1920x1080 so I added these

elif str(resolution).lower() in ['1072p', '1072', 'fhd']:
            info_url = "http://www.crunchyroll.com/xml/?req=RpcApiVideoPlayer_GetStandardConfig&media_id=%s&video_format=106&video_quality=62&current_page=%s" % (
                video_id, url)
            resolution_to_find = "1920x1072"

but I saw your message:

Trying to login...
Traceback (most recent call last):
  File "D:\anime-dl\anime_dl\__main__.py", line 18, in <module>
    class main():
  File "D:\anime-dl\anime_dl\__main__.py", line 75, in main
    logger=logger, episode_range=args.range)
  File "D:\anime-dl\anime_dl\AnimeDL.py", line 30, in __init__
    skipper=skipper, logger=logger, episode_range=episode_range)
  File "D:\anime-dl\anime_dl\sites\crunchyroll.py", line 68, in __init__
    cookies, Token = self.webpagedownloader(url=url, username=username[0], password=password[0], country=Crunchy_Language)
  File "D:\anime-dl\anime_dl\sites\crunchyroll.py", line 135, in webpagedownloader
    if self.login_check(htmlsource=login_post.text.encode('utf-8')):
  File "D:\anime-dl\anime_dl\sites\crunchyroll.py", line 80, in login_check
    if '<a href="/logout"' in htmlsource:
TypeError: a bytes-like object is required, not 'str'

I downloaded @Nicnl fork of this project.

anyone have any idea about this issue?

Abu3safeer commented 5 years ago

I tried to fix this by converting htmlsource from byte to string, but the broke the download process, so I will leave it for people who understand python.

Xonshiz commented 5 years ago

Check the latest binary now.

axipher commented 5 years ago

So which version of Python should we be using, the ReadMe just says Python 3

Xonshiz commented 4 years ago

It should work on both. When I had started this project, Python 2 was the choice. But, then I had made changes that would make this work on both, Python 3 and Python 2.

I'll try to re-write things by next week and see if it's any better.

axipher commented 4 years ago

Thanks @Xonshiz for the work on this

axipher commented 4 years ago

Still getting error running on Windows PowerShell with Python 3.7.4 with latest code

PS C:\anime-dl\anime-dl-master\anime_dl> python __main__.py -v -i https://www.crunchyroll.com/en/full-metal-panic -u username -p password
Trying to login...
Traceback (most recent call last):
  File "__main__.py", line 22, in <module>
    class Main():
  File "__main__.py", line 79, in Main
    logger=logger, episode_range=args.range)
  File "C:\anime-dl\anime-dl-master\anime_dl\Anime_dl.py", line 30, in __init__
    skipper=skipper, logger=logger, episode_range=episode_range)
  File "C:\anime-dl\anime-dl-master\anime_dl\sites\crunchyroll.py", line 36, in __init__
    country=crunchy_language)
  File "C:\anime-dl\anime-dl-master\anime_dl\common\browser_instance.py", line 76, in login_crunchyroll
    login_check_response, login_cookies = login_check(html_source=login_post.text.encode('utf-8'), cookies=login_post.cookies)
  File "C:\anime-dl\anime-dl-master\anime_dl\common\browser_instance.py", line 92, in login_check
    if "href=\"/logout\"" in html_source:
TypeError: a bytes-like object is required, not 'str'

PS C:\anime-dl\anime-dl-master\anime_dl> python --version
Python 3.7.4