-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
Add Cinemast provider #817
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
subliminal/providers/cinemast.py
Outdated
|
||
self.session = None | ||
self.username = username or self.default_username | ||
self.password = password or self.default_password |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there a default user?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API is accessible only to registered users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, removed.
subliminal/providers/cinemast.py
Outdated
self.session.headers['User-Agent'] = 'Subliminal/{}'.format(__short_version__) | ||
|
||
# login | ||
if self.username and self.password: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will always evaluate to True
with default values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verification is for user input (in case None
or an ''
were inserted).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ofir123
do like legendastv:
if self.username is not None and self.password is not None:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.username = username or self.default_username
this already takes care of that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
subliminal/providers/cinemast.py
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about other characters? e.g. dot, semicolons
Is there any other way to get this information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
urlencode is required here due to above comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
else: | ||
titles = [video.title] + video.alternative_titles | ||
|
||
for title in titles: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Diaoul It will stop in the first result found. And dogpile caches it so next time it won't hit server.
subliminal/providers/cinemast.py
Outdated
# download | ||
url = self.server_url + 'subtitle/download/{}/'.format(subtitle.language.alpha2) | ||
params = { | ||
'v': subtitle.releases[0], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the result change if you take another release?
subliminal/providers/cinemast.py
Outdated
matches.add('episode') | ||
# guess | ||
for release in self.releases: | ||
matches |= guess_matches(video, guessit(release, {'type': 'episode'})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
subliminal/providers/cinemast.py
Outdated
elif isinstance(video, Movie): | ||
# guess | ||
for release in self.releases: | ||
matches |= guess_matches(video, guessit(release, {'type': 'movie'})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
subliminal/providers/cinemast.py
Outdated
|
||
# otherwise create it | ||
subtitle = self.subtitle_class(language, page_link, title, season, episode, title, subtitle_id, | ||
subtitle_key, [release]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 release = 1 instance
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.