Add plugins for Gazelle-based sites (including RED and NWCD)#2017
Add plugins for Gazelle-based sites (including RED and NWCD)#2017
Conversation
2b94afd to
8179b12
Compare
3d019c2 to
709376d
Compare
flexget/plugins/input/gazelle.py
Outdated
There was a problem hiding this comment.
instance variables should be in lowercase
There was a problem hiding this comment.
I agree with you, however, these are more like instance constants. They're changed during the initial setup of the class but should stay static after that point.
There was a problem hiding this comment.
i dont think it matters. even if they're changed on inheritence, they're still instance variables which is the equivilant of const, and should be lowercase. no biggie though
flexget/plugins/input/gazelle.py
Outdated
flexget/plugins/input/gazelle.py
Outdated
There was a problem hiding this comment.
Using else would break in the case where no base_url is in the config but one is set up on the subclass so it doesn't need to be configured.
flexget/plugins/input/gazelle.py
Outdated
There was a problem hiding this comment.
this check is redundant since you provided a default
flexget/plugins/input/gazelle.py
Outdated
There was a problem hiding this comment.
I'm assuming this is more about the wrapping and less about the method of doing it? I was keeping to 80 chars out of habit but have just noticed that 120 is what's configured in setup.py - I'll unwrap the line since it's only 100 unwrapped.
flexget/plugins/input/gazelle.py
Outdated
flexget/plugins/input/gazelle.py
Outdated
There was a problem hiding this comment.
should be moved to exception handling
There was a problem hiding this comment.
This response is a 200 in a success case. Any other 3xx or 2xx response, while not considered an error to requests, is considered an error at this point in execution.
flexget/plugins/input/gazelle.py
Outdated
flexget/plugins/input/gazelle.py
Outdated
There was a problem hiding this comment.
this only works for python 3 IMO
flexget/plugins/input/gazelle.py
Outdated
There was a problem hiding this comment.
change to be python 2 compatible
709376d to
734cac6
Compare
68672c2 to
48a85cf
Compare
|
|
||
| # Logged in successfully, it's ok if nothing matches now | ||
| task.no_entries_ok = True | ||
|
|
flexget/plugins/input/gazelle.py
Outdated
| self._session.cookies.clear() | ||
|
|
||
| if not force: | ||
| with FlexgetSession() as session: |
There was a problem hiding this comment.
We prefer if task.requests is used whenever possible.
flexget/plugins/input/gazelle.py
Outdated
| torrent_seeds=tor['seeders'], | ||
| torrent_leeches=tor['leechers'], | ||
| # Size is returned in bytes, convert to MB for compat with the content_size plugin | ||
| content_size=tor['size'] / (1024 ** 2) |
There was a problem hiding this comment.
I did see that but didn't think it was appropriate. That function takes a string, guesses the correct units, and converts it to MB. To use it I would have to do something like:
Entry(
content_size=parse_filesize(str(tor['size']) + "b")
)Is that preferred over just converting it manually?
There was a problem hiding this comment.
It might be a good idea to create a function that does that. It's not the first time we've needed it. Or making it default to bytes if no unit is found.
flexget/plugins/input/gazelle.py
Outdated
| return list(self.get_entries(self.search_results(params))) | ||
|
|
||
|
|
||
| class InputRedacted(InputGazelle): |
There was a problem hiding this comment.
The plugins that inherit from InputGazelle should be in separate files. Not sure where to put InputGazelle... maybe utils?
There was a problem hiding this comment.
Yeah, we don't really have a precedence for this. Making it part of core feels weird so I think it's best that all plugins be places together to avoid import issues
There was a problem hiding this comment.
There's a lot of coupling between them and I worry that if they were split up it would be really easy to make a change in one of them that would break the others. Keeping them in the same file would help make it easier for people unfamiliar with the code to understand the implications of changing a parent class.
Ex: InputNotWhat inherits from InputRedacted. To set up the params and schema it just uses the parent classes values and adds/changes things. If RED makes a change and adds a releasetype and someone updates the plugin to include it without taking into account the child, it could break the NWCD plugin. Granted this is kinda messy anyway, but alternative was redefining the entire PARAMS structure which seemed like overkill since it's 95% the same.
This also holds true for things like cookies. If the InputRedacted plugin switched from using a cookie called session to one called red_session and the plugin is updated, InputNotWhat will break
To be honest I'm not totally happy with having InputNotWhat inherit from InputRedacted anyway so I'll look into solving this with a better inheritance model.
EDIT: Latest commit alleviates some of these concerns
e39c081 to
e0c7d8e
Compare
flexget/plugins/input/gazelle.py
Outdated
There was a problem hiding this comment.
A nitpick: We divide imports into four groups:
- future
- builtin
- flexget
- 3rd party.
So the sqlalchemy import should be moved down a line.
flexget/plugins/input/gazelle.py
Outdated
There was a problem hiding this comment.
We don't typically include the TLD in the plugin name unless it's part of the site name... It should just be redacted
|
I think it's fine now. Don't worry about the commits, we squash the entire pr on merge |
4b8b437 to
3068a70
Compare
flexget/plugins/input/gazelle.py
Outdated
There was a problem hiding this comment.
Is this necessary? We already set a user_agent in task.requests (https://github.com/Flexget/Flexget/blob/develop/flexget/utils/requests.py#L184)
flexget/plugins/input/gazelle.py
Outdated
There was a problem hiding this comment.
You don't need to return False. No return statement is the same as return None
There was a problem hiding this comment.
The reason I explicitly return False is that having it return True/False vs. True/None is a little more logical IMO. Same reason why I don't return True/0 even though it would behave the same way when used in truthyness comparisons.
flexget/plugins/input/gazelle.py
Outdated
There was a problem hiding this comment.
Nitpick: Shouldn't this be called account_info?
flexget/plugins/input/gazelle.py
Outdated
There was a problem hiding this comment.
I don't think this linebreak is necessary. We allow 120 chars.
cvium
left a comment
There was a problem hiding this comment.
My recent comments are purely stylistic, so you don't have to do them, but I really want the content_size to use our util (feel free to change it to default to bytes if no unit is provided).
3068a70 to
7935543
Compare
|
@cvium Fixed up style issues and switched to using |
flexget/plugins/input/gazelle.py
Outdated
There was a problem hiding this comment.
We already have a plugin for this though https://flexget.com/Plugins/headers
There was a problem hiding this comment.
That's useful, I didn't know about that - I've removed the custom UA support from the plugin
Plugin features:
- Can function as a search plugin or a task.
- Stores sessions in the DB to minimize logins.
- Configurable page limit (don't scrape the entire site accidentally)
- Extensible classes to allow adding other gazelle-based sites with
minimal effort.
Provided plugins:
- Two generic plugins:
- The 'gazelle' plugin should work for the vast majority of Gazelle-
based sites, albeit with limited functionality.
- The 'gazellemusic' plugin is compatible with the latest version of
the public WhatCD Gazelle source. As most Gazelle-based music sites
will have used that code as a starting point, this class should work
for them.
- Two specific plugins:
- The 'redacted' plugin is a customized version of the 'gazellemusic'
plugin that works with RED's modifications to the Gazelle source.
- The 'notwhatcd' plugin is the same thing for NWCD.
7935543 to
a7c9254
Compare
|
Thanks. Wanna update the wiki? |
|
Added a wiki page: https://www.flexget.com/Searches/gazelle |
|
Looks great |
Motivation for changes:
Add capability to search Gazelle-based sites
Detailed changes:
To Do:
searchinterface