Repository: Flexget/Flexget

Issue:
t411 : BUG: Unhandled error in plugin discover: maximum recursion depth exceeded while getting the str of an object
I've got an error when executing my flexget script

flexget execute --task tv-t411 --discover-now

This is the config file
http://pastie.org/10809799

And this is the crash log

[crash_report.2016.04.23.150112065543.zip](https://github.com/Flexget/Flexget/files/233121/crash_report.2016.04.23.150112065543.zip)



Discussion:
Please paste them here or via a paste service 

I put the config in the paste service.
But the crash log is too large at 90kb which is bigger than 64 kb

Dead link to config 

Reupdated sorry, 1st time using those services

I think the error is here

https://github.com/Flexget/Flexget/blob/646d6ed86a79599ff1c9aba9107cadbccfddff77/flexget/plugins/api_t411.py#L642-L642

It's trying to filter on a model field but i'm not sure what it's meant to be using to filter.. @lildadou can u shed any light here?

actually no second thoughts, i'm not sure what's going on there.. not familiar with t411 :|

Command [L638-642](https://github.com/Flexget/Flexget/blob/646d6ed86a79599ff1c9aba9107cadbccfddff77/flexget/plugins/api_t411.py#L638-L642) goal is find its termtype identifier and its own identifier.

So I join term and term type with `Term.type_id == TermType.id`, I exclude TermType were aren't in the user category with `TermType.categories.any(Category.id == category_id)`. This is the term class model for a better comprehension :
![t411-term relations](https://cloud.githubusercontent.com/assets/433604/14777116/4b783422-0acb-11e6-8bd0-5a4f0a1617a3.png)

I do not understand why there is an error.
@kevmegforest: Can you provide a debug level log?

I'll look at it this weekend 

Here's the debug log.

At line 2983, it's true that the string is pretty long. I really don't know why it's searching with all those terms.

[flexgetDebug.log.txt](https://github.com/Flexget/Flexget/files/249453/flexgetDebug.log.txt)

Look over your config. Seems your merging things multiple times.

@lildadou what is the purpose of https://github.com/Flexget/Flexget/blob/646d6ed86a79599ff1c9aba9107cadbccfddff77/flexget/plugins/api_t411.py#L115-L119?

You keep on adding episode identifiers to the list and then you do query concatenation with `|=` operator. I'm not surprised he gets this error.

It basically becomes a select statement consisting of _at least_ 152 different selects (based on his log).

One question, why is the plugin searching using those terms "Episode 1" etc? There's a lot of files on t411 that are not properly tagged. I think It's better to just use the series name while searching than to use those tags that can filter a lot of things out.

@stevezau I think you should remove the pending information label.

Pending information from @lildadou.

@cvium : `add_season_term` is just a shortcut for adding a type of term (season).
Ok, the mistake is at https://github.com/Flexget/Flexget/blob/develop/flexget/plugins/plugin_torrent411.py#L57 : I return the same list of terms and mutate it rather than instantiate a new. I will fix it.

@kevmegforest : Because t411 search engine is currently bugged ; it's a hack.

@lildadou Cool. Mystery solved.


Resolving patch:
diff --git a/flexget/plugins/plugin_torrent411.py b/flexget/plugins/plugin_torrent411.py
old mode 100644
new mode 100755
--- a/flexget/plugins/plugin_torrent411.py
+++ b/flexget/plugins/plugin_torrent411.py
@@ -61,7 +61,7 @@ def build_request_from(config):
         """
         query = FriendlySearchQuery()
         query.category_name = config.get('category')
-        query.term_names = config.get('terms', [])
+        query.term_names = list(config.get('terms', []))
         query.max_results = config.get('max_results')
         return query
 


Test patch: