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

Unexpected crash in plugin discover: NoneType object has no attribute 'text' #1643

Closed
zepheris opened this issue Jan 18, 2017 · 21 comments · Fixed by #1651
Closed

Unexpected crash in plugin discover: NoneType object has no attribute 'text' #1643

zepheris opened this issue Jan 18, 2017 · 21 comments · Fixed by #1651

Comments

@zepheris
Copy link

zepheris commented Jan 18, 2017

Expected behaviour:

List of new episodes are sent to remote deluge daemon

Actual behaviour:

Unexpected crash has occurred.
BUG: Unhandled error in plugin discover: 'NoneType' object has no attribute 'text'

Steps to reproduce:

I can reproduce it using my config, but I'm unable to figure out how to gather more detailed information (aside from setting flexget's log to debug).

This issue didn't start occurring until I updated flexget to the latest version. Since then, I've tried the latest version as well as the development version. I've even tried different versions of Python. At the time of this writing, I'm using:

flexget 2.9.7.dev
python 2.7.9

I'm pretty new at flexget, but I think the issue with related with this search string:
https://iptorrents.com/t?4=&5=&22=&q=Teen+Wolf+S06E08&qf=

Config:

http://pastebin.com/6sLVmUSe

Log:

http://pastebin.com/AY1pqZuP

Additional information:

@zepheris zepheris changed the title Unexpected crash while parsing Unexpected crash in plugin discover: NoneType object has no attribute 'text' Jan 18, 2017
@liiight
Copy link
Member

liiight commented Jan 18, 2017

Iptorrents change probably:

File "/root/flexget-dev/flexget/plugins/sites/iptorrents.py", line 150, in search
 *, entry['title'] = torrent.findPrevious("a", attrs={'class': 't_title'}).text
AttributeError: 'NoneType' object has no attribute 'text'

@zepheris
Copy link
Author

How can I help figure out what changed?

@lostinaudio
Copy link

I'm having this same issue with my iptorrents search. Is there a fix yet?

@frankyw
Copy link

frankyw commented Jan 18, 2017

I am also having a similar problem with the iptorrents plugin, which I've had to disable temporarily. Not sure if they are related?

2017-01-17 23:15 CRITICAL task          download-movies BUG: Unhandled error in plugin discover: a bytes-like object is required, not 'str'
Traceback (most recent call last):
  File "/home/frank/flexget/lib/python3.5/site-packages/flexget/task.py", line 490, in __run_plugin
    return method(*args, **kwargs)
  File "/home/frank/flexget/lib/python3.5/site-packages/flexget/event.py", line 23, in __call__
    return self.func(*args, **kwargs)
  File "/home/frank/flexget/lib/python3.5/site-packages/flexget/plugins/input/discover.py", line 290, in on_task_input
    return self.execute_searches(config, entries, task)
  File "/home/frank/flexget/lib/python3.5/site-packages/flexget/plugins/input/discover.py", line 155, in execute_searches
    search_results = search.search(task=task, entry=entry, config=plugin_config)
  File "/home/frank/flexget/lib/python3.5/site-packages/flexget/plugin.py", line 118, in wrapped_func
    return func(*args, **kwargs)
  File "/home/frank/flexget/lib/python3.5/site-packages/flexget/plugins/sites/iptorrents.py", line 140, in search
    if '/u/' + str(config.get('uid')) not in req.content:
TypeError: a bytes-like object is required, not 'str'

@cvium
Copy link
Contributor

cvium commented Jan 18, 2017

The only chance of a fix is if someone creates a PR. None on the 'team' have access to IPT.

@frankyw that issue is unrelated.

@zepheris
Copy link
Author

zepheris commented Jan 18, 2017

I think I understand how the parser works. From what I can see, the parser is looking for <td class="some name"> I have a snip of the search results of the IP torrents link. Let me know if I'm on the right track

http://pastebin.com/C2zXd286

@frankyw
Copy link

frankyw commented Jan 18, 2017

Yes, they have removed the class t_title from the href, so it is a little more difficult to reference. Trying to fix it now.

@zepheris
Copy link
Author

I found the fix

Change iptorrents.py where its referring to class="t_title" to "b"

@zepheris
Copy link
Author

zepheris commented Jan 18, 2017

image

I updated my local file and it completed successfully. I have no clue how to do a PR or if there are other ways to test to see if this change will cause new problems. Let me know how I can help :)

@frankyw
Copy link

frankyw commented Jan 18, 2017

And if you are using Python 3.5, you also need to change line 140 to fix the other error I posted:

if '/u/' + str(config.get('uid')) not in req.content.decode('utf-8'):

@lostinaudio
Copy link

where would i find my local iptorrents.py file?

@zepheris
Copy link
Author

zepheris commented Jan 19, 2017

That would depend on your OS as well as how you installed flexget. Try searching for iptorrents.py on the computer.

@gazpachoking
Copy link
Member

if '/u/' + str(config.get('uid')) not in req.content.decode('utf-8'):

This could be simplified to: if '/u/' + config['uid'] not in req.text:

'uid' is a required config element, (so no need for the 'get',) and is already text, (so no need for the 'str()'.) Requests also provides the '.text' attribute, which is the content decoded to text already.

If someone who is capable of testing wants to make a PR with the fixes you guys found it would be appreciated.

@zepheris
Copy link
Author

zepheris commented Jan 19, 2017

@gazpachoking

I've never submitted a PR before, but I'll try to submit one sometime this weekend.
(if anybody else wants to do that beforehand, I won't be angry, LOL)

@ianstalk
Copy link
Contributor

'uid' is a required config element, (so no need for the 'get',) and is already text

It's optionally text. I think this should work:
if u'/u/' + unicode(config['uid']) not in req.content:

@gazpachoking
Copy link
Member

It's optionally text. I think this should work:
if u'/u/' + unicode(config['uid']) not in req.content:

Ahh, it can be an int as well. In that case it should be str not unicode (python 3 style)

if '/u/' + str(config['uid']) not in req.text:

@ianstalk
Copy link
Contributor

Weird, where's that TypeError @frankyw mentioned coming from, then? I'm not using Python 3 so I can't test.

@gazpachoking
Copy link
Member

Weird, where's that TypeError @frankyw mentioned coming from, then? I'm not using Python 3 so I can't test.

That was because the begining bit is text, ('/u/' + str(whatever)), and the end bit was bytes (req.content). Changing to req.text means both sides of the 'in' are text, which resolves that error.

@ianstalk
Copy link
Contributor

Got it. I'll have a PR ready in a few minutes.

@frankyw
Copy link

frankyw commented Jan 23, 2017

@gazpachoking thank you for your more elegant solution, I am not a python coder and hence relied on Google+trial and error :)

@ianstalk thanks for doing this PR, much appreciated. I can confirm @gazpachoking's fix works fine on Python 3.5

@zepheris
Copy link
Author

Thanks @ianstalk for doing the PR. Very much appreciated.

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

Successfully merging a pull request may close this issue.

7 participants