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

Add Cinemast provider #817

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

ofir123
Copy link
Contributor

@ofir123 ofir123 commented Oct 2, 2017

Fixed SubsCenter provider to work with the new API.

Copy link
Collaborator

@fernandog fernandog left a 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?

@fernandog
Copy link
Collaborator

@ofir123 also http://www.subscenter.info/he/ still exists

@ofir123
Copy link
Contributor Author

ofir123 commented Nov 18, 2017

This provider is based on the SubsCenter Kodi plugin.
I think they're the same (Cinemast is just an alternative name).. but of course I'll rename it if it's a problem.
subscenter still exists, but they added a CAPTCHA so automatic downloads are problematic.

@fernandog
Copy link
Collaborator

@ofir123 ok but if site is Cinemast I would rename to not confuse users

@ofir123 ofir123 changed the title Feature/new subscenter support Feature/new cinemast provider Nov 29, 2017
@ofir123
Copy link
Contributor Author

ofir123 commented Nov 29, 2017

Renamed to Cinemast!

@fernandog
Copy link
Collaborator

@ofir123 can you merge develop branch into this branch? Or rebase on develop

@ofir123
Copy link
Contributor Author

ofir123 commented Nov 29, 2017

Sure, rebased now.

@fernandog
Copy link
Collaborator

When you rebase only your commits should appear

@fernandog
Copy link
Collaborator

@ofir123 do this:

git checkout origin/develop
git pull
git checkout feature/new-subscenter-support
git rebase develop feature/new-subscenter-support
git push feature/new-subscenter-support -f

@ofir123 ofir123 force-pushed the feature/new-subscenter-support branch from 25b6d93 to 2bf87ef Compare November 29, 2017 21:45
@ofir123
Copy link
Contributor Author

ofir123 commented Nov 29, 2017

Oh sorry about that :
Wrong direction.. fixed it now (and thanks for the tips @fernandog )

@fernandog
Copy link
Collaborator

@ofir123 still has duplicate commits. I will try to fix tomorrow

@fernandog fernandog force-pushed the feature/new-subscenter-support branch from 2bf87ef to 5d74d55 Compare November 29, 2017 23:29
@fernandog
Copy link
Collaborator

@ofir123 fixed

@fernandog fernandog changed the title Feature/new cinemast provider Add Cinemast provider Nov 29, 2017
@fernandog fernandog dismissed their stale review November 29, 2017 23:40

Already renamed

@fernandog
Copy link
Collaborator

fernandog commented Nov 29, 2017

@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?

@ofir123
Copy link
Contributor Author

ofir123 commented Nov 30, 2017

@fernandog thnx for the fixes!
I've added the test you requested..

@fernandog fernandog force-pushed the feature/new-subscenter-support branch from 90063b5 to ecd885d Compare November 30, 2017 22:13
@fernandog
Copy link
Collaborator

@ofir123 all tests passing

@Diaoul this is the the subscenter provider (which is in master) that got renamed to Cinemast.
Good to merge?


self.session = None
self.username = username or self.default_username
self.password = password or self.default_password
Copy link
Owner

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?

Copy link
Contributor Author

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.

Copy link
Owner

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.

Copy link
Contributor Author

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..

Copy link
Owner

@Diaoul Diaoul Dec 1, 2017

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, removed.

self.session.headers['User-Agent'] = 'Subliminal/{}'.format(__short_version__)

# login
if self.username and self.password:
Copy link
Owner

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.

Copy link
Contributor Author

@ofir123 ofir123 Dec 1, 2017

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).

Copy link
Collaborator

@fernandog fernandog Dec 1, 2017

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:

Copy link
Owner

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

subtitles = {}
for group_data in results.get('data', []):
# create page link
slug_name = group_data.get('name_en').lower().replace(' ', '-').replace('\'', '').replace('"', '')
Copy link
Owner

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?

Copy link
Contributor Author

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.

Copy link
Owner

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)
Copy link
Owner

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Collaborator

@fernandog fernandog Dec 1, 2017

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

Copy link
Owner

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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Contributor Author

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:
Copy link
Owner

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.

Copy link
Collaborator

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.

# download
url = self.server_url + 'subtitle/download/{}/'.format(subtitle.language.alpha2)
params = {
'v': subtitle.releases[0],
Copy link
Owner

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?

matches.add('episode')
# guess
for release in self.releases:
matches |= guess_matches(video, guessit(release, {'type': 'episode'}))
Copy link
Owner

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.

Copy link
Contributor Author

@ofir123 ofir123 Dec 1, 2017

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?

Copy link
Owner

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.

elif isinstance(video, Movie):
# guess
for release in self.releases:
matches |= guess_matches(video, guessit(release, {'type': 'movie'}))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here


# otherwise create it
subtitle = self.subtitle_class(language, page_link, title, season, episode, title, subtitle_id,
subtitle_key, [release])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 release = 1 instance

@ofir123
Copy link
Contributor Author

ofir123 commented Dec 1, 2017

OK, fixed multiple releases issue. @Diaoul

@ofir123
Copy link
Contributor Author

ofir123 commented Dec 1, 2017

@fernandog How do you fix the tests? Is there something I'm doing wrong with the cassettes?

@fernandog
Copy link
Collaborator

all good now

@ofir123
Copy link
Contributor Author

ofir123 commented Dec 5, 2017

@Diaoul @fernandog So what's missing for the merge?

@smoresmores
Copy link

smoresmores commented May 7, 2018

What is the status of this?
@ofir123 @fernandog @Diaoul

@ofir123
Copy link
Contributor Author

ofir123 commented May 8, 2018

@smoresmores It's ready.. just waiting for the merge..

@ratoaq2 ratoaq2 self-assigned this Feb 24, 2019
@ratoaq2 ratoaq2 added this to the 2.1 milestone Feb 24, 2019
# Conflicts:
#	setup.py
#	subliminal/cli.py
#	subliminal/extensions.py
#	tests/test_extensions.py
@ofir123
Copy link
Contributor Author

ofir123 commented Apr 25, 2019

Hey @ratoaq2 !
Any chance this will get merged in the upcoming version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants