Add Cinemast provider#817
Conversation
fernandog
left a comment
There was a problem hiding this comment.
Provider should be called cinemast now right?
|
@ofir123 also http://www.subscenter.info/he/ still exists |
|
This provider is based on the SubsCenter Kodi plugin. |
|
@ofir123 ok but if site is Cinemast I would rename to not confuse users |
|
Renamed to Cinemast! |
|
@ofir123 can you merge develop branch into this branch? Or rebase on develop |
|
Sure, rebased now. |
|
When you rebase only your commits should appear |
|
@ofir123 do this: git checkout origin/develop |
25b6d93 to
2bf87ef
Compare
|
Oh sorry about that : |
|
@ofir123 still has duplicate commits. I will try to fix tomorrow |
2bf87ef to
5d74d55
Compare
|
@ofir123 fixed |
|
@ofir123 can you add a test like legendastv that would only match a title if using an alternative title? Do you know one case that only return results when searching with alternative title? |
Only movies has `title` as match
|
@fernandog thnx for the fixes! |
90063b5 to
ecd885d
Compare
|
|
||
| self.session = None | ||
| self.username = username or self.default_username | ||
| self.password = password or self.default_password |
There was a problem hiding this comment.
API is accessible only to registered users.
There was a problem hiding this comment.
In that case, don't provide a default user, just use this one for testing and require USER and PASSWORD to be provided in the CLI.
I don't think we have private-only providers so this is all new for you to do.
There was a problem hiding this comment.
I really don't think this is necessary for this provider, since it's not really private.
Only the API requires user and password, and the actual website doesn't.
They don't really care about it being a default user as far as I can tell..
There was a problem hiding this comment.
If/When they introduce a limited number of downloads per user this is not going to work anymore. Moreover this is not a widely used providers as per the only language it supports. I don't think people would mind entering a user/password in their command line.
Unless you have explicit agreement with Cinemast to use a default user I'd rather require subliminal users to register.
A websites generates ad-revenue, an API does not. does not so maybe api restriction is intentional.
| self.session.headers['User-Agent'] = 'Subliminal/{}'.format(__short_version__) | ||
|
|
||
| # login | ||
| if self.username and self.password: |
There was a problem hiding this comment.
This will always evaluate to True with default values.
There was a problem hiding this comment.
Verification is for user input (in case None or an '' were inserted).
There was a problem hiding this comment.
@ofir123
do like legendastv:
if self.username is not None and self.password is not None:
There was a problem hiding this comment.
self.username = username or self.default_username this already takes care of that.
| subtitles = {} | ||
| for group_data in results.get('data', []): | ||
| # create page link | ||
| slug_name = group_data.get('name_en').lower().replace(' ', '-').replace('\'', '').replace('"', '') |
There was a problem hiding this comment.
What about other characters? e.g. dot, semicolons
Is there any other way to get this information?
There was a problem hiding this comment.
Not really..
It's not my site so I'm just guessing and checking how to replace each character.
I'll added dot and semicolons though! Good idea.
There was a problem hiding this comment.
Make this a function so it doesn't look too long.
| # create page link | ||
| slug_name = group_data.get('name_en').lower().replace(' ', '-').replace('\'', '').replace('"', '') | ||
| if query['type'] == 'series': | ||
| page_link = self.server_url + 'subtitle/series/{}/{}/{}/'.format(slug_name, season, episode) |
There was a problem hiding this comment.
urlencode is required here due to above comment.
There was a problem hiding this comment.
@Diaoul urlencode is from urllib right? Requests already does the encoding and it's not needed. confirm?
no other provider uses urlencode
There was a problem hiding this comment.
For params or data you are correct but even for the URL requests does that? Anyway, I'm not sure this makes any sense as with special characters the URL will probably be wrong no? If you can add tests that pass with accentuated characters and weird characters that'll be fine for me.
| if query['type'] == 'series': | ||
| page_link = self.server_url + 'subtitle/series/{}/{}/{}/'.format(slug_name, season, episode) | ||
| else: | ||
| page_link = self.server_url + 'subtitle/movie/{}/'.format(slug_name) |
| else: | ||
| titles = [video.title] + video.alternative_titles | ||
|
|
||
| for title in titles: |
There was a problem hiding this comment.
As I said before, this is going to flood the servers with many useless requests sometimes returning duplicated results. I'm really not a big fan of this.
There was a problem hiding this comment.
@Diaoul It will stop in the first result found. And dogpile caches it so next time it won't hit server.
| # download | ||
| url = self.server_url + 'subtitle/download/{}/'.format(subtitle.language.alpha2) | ||
| params = { | ||
| 'v': subtitle.releases[0], |
There was a problem hiding this comment.
Does the result change if you take another release?
| matches.add('episode') | ||
| # guess | ||
| for release in self.releases: | ||
| matches |= guess_matches(video, guessit(release, {'type': 'episode'})) |
There was a problem hiding this comment.
This is potentially going to give an unreal good score to the subtitles as this is the union of all releases instead of picking the best.
There was a problem hiding this comment.
Not sure I understand what you mean..
If the subtitle matches multiple releases, I want to check all of them.
Should I change it so each subtitle will match only one release?
There was a problem hiding this comment.
I don't know in that case if we shouldn't do a single Subtitle instance for each release. Even if this is the same actual subtitle.
I think for now if it does the job leave it as is but that's a thought for the long term.
@pannal: what about harmonizing the Subtitle object so that it's not provider specific but rather "subliminal"-specific? This would avoid you patching all the subtitle classes to change the guessing rules. Not sure the feasability though.
| elif isinstance(video, Movie): | ||
| # guess | ||
| for release in self.releases: | ||
| matches |= guess_matches(video, guessit(release, {'type': 'movie'})) |
|
|
||
| # otherwise create it | ||
| subtitle = self.subtitle_class(language, page_link, title, season, episode, title, subtitle_id, | ||
| subtitle_key, [release]) |
|
OK, fixed multiple releases issue. @Diaoul |
|
@fernandog How do you fix the tests? Is there something I'm doing wrong with the cassettes? |
|
all good now |
|
@Diaoul @fernandog So what's missing for the merge? |
|
What is the status of this? |
|
@smoresmores It's ready.. just waiting for the merge.. |
# Conflicts: # setup.py # subliminal/cli.py # subliminal/extensions.py # tests/test_extensions.py
|
Hey @ratoaq2 ! |
Because Travis Ci is on vacation.
Fixed SubsCenter provider to work with the new API.