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

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

Open
voyager-nx24 opened this issue Apr 24, 2019 · 12 comments
Open

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

voyager-nx24 opened this issue Apr 24, 2019 · 12 comments
Assignees
Labels

Comments

@voyager-nx24
Copy link

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
Copy link

axipher commented Apr 24, 2019

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): #86 (comment)

@voyager-nx24
Copy link
Author

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
Copy link

axipher commented Apr 24, 2019

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

@Nicnl
Copy link
Contributor

Nicnl commented Apr 25, 2019

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Owner

Xonshiz commented May 26, 2019

Check the latest binary now.

@axipher
Copy link

axipher commented Jul 24, 2019

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

@Xonshiz
Copy link
Owner

Xonshiz commented Oct 22, 2019

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.

@Xonshiz Xonshiz added the bug label Oct 22, 2019
@Xonshiz Xonshiz self-assigned this Oct 22, 2019
@axipher
Copy link

axipher commented Oct 22, 2019

Thanks @Xonshiz for the work on this

@axipher
Copy link

axipher commented Nov 8, 2019

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

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

No branches or pull requests

5 participants