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

fixed: Properly handle stacked files for subtitles #4274

Merged
merged 1 commit into from
Mar 3, 2014

Conversation

arnova
Copy link
Member

@arnova arnova commented Feb 24, 2014

This is a followup for #4196 & #3819. Note that #4196 multi-sub implementation is pretty flawed and this should fix that.

Note that I'm not sure our current subtitle API is flexible/capable enough to properly handle future-support for stacked/multiple subtitles. For what we have, this seems to be the best approach, but of course any suggestions/discussions are welcome. And since we're still pre-Gotham-beta, this would be the time if we want to change our API after all.

@arnova
Copy link
Member Author

arnova commented Feb 24, 2014

@jmarshallnz : Please comment/review. jenkins build this please

@amet
Copy link
Contributor

amet commented Feb 24, 2014

what would the API change be? as it is subtitle services can(if they support it) return more than one subtitle file, is that not enough?

see here how we can get more than one subtitle -> https://github.com/amet/service.subtitles.opensubtitles/blob/Gotham/service.subtitles.opensubtitles/service.py#L61

we need to send stack=True to it and it should try to get all.

note that I have zero stacked files and in all these years have successfully stayed away from it, so I could be a wrong person to comment :)

}

// Make sure (stack) size is the same is the size of the items handed to us (this includes non-stack items!)
if (vecFiles.size() != (unsigned int) items->Size())

This comment was marked as spam.

This comment was marked as spam.

@arnova
Copy link
Member Author

arnova commented Feb 24, 2014

@amet, I vaguely recall looking at that code before and at least back then there was some stuff missing to make it work properly (I think the zip unpacker + correctly naming/ordering the individual files was the problem). We also need the possibility to fallback to single items, meaning the user should have the option to download a stacked (multi-file) sub but also the ability to select single subs (like how it is now) as the service may not offer a correct one for one or the other.

{
CStdString subPath = CSpecialProtocol::TranslatePath("special://subtitles");
if (!subPath.empty())
strDownloadPath = subPath;

strFileName = URIUtils::GetFileName(strCurrentFile);
// Handle stacks: Make sure (stack) size is the same as the size of the items handed to us
if (g_application.CurrentFileItem().IsStack() && items->Size() > 1 && items->Size() == (int) vecFiles.size())

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@amet
Copy link
Contributor

amet commented Feb 25, 2014

@arnova we will be limited to whatever the service provider gives us. If you find me on IRC(or e-mail me) we can discuss whats needed and see if we have that in any of the services that offer API(opensubtitles, podnapisi) as all others are just scraping the websites and chances are that there will be nothing there.

@arnova
Copy link
Member Author

arnova commented Feb 25, 2014

@jmarshallnz : Updated
@amet / @jmarshallnz : Note the stack=true url option I've added, which the addons can use to determine whether they also need to fetch multi-file subs. @amet: Please have a look, I'll try to catch you on IRC one of these days to discuss the Python implementation.

@MartijnKaijser MartijnKaijser added this to the Pending for inclusion milestone Feb 27, 2014
@arnova
Copy link
Member Author

arnova commented Feb 28, 2014

@jmarshallnz : Any (additional) ideas about this? I think we (also) need some way to flag stacked subs (= zip archive with multiple subtitles) in the subtitle dialog.

@amet
Copy link
Contributor

amet commented Mar 2, 2014

@arnova stack=true helps, thats a good idea as it saves checking for it in script all the time

@jmarshallnz
Copy link
Contributor

ok from my perspective. jenkins build this please

@arnova
Copy link
Member Author

arnova commented Mar 3, 2014

@t-nelson / @jmarshallnz : So this can be merged before we branch?

@@ -325,6 +328,10 @@ void CGUIDialogSubtitles::Search(const std::string &search/*=""*/)
if (setting)
url.SetOption("languages", setting->ToString());

// Check for stacking
if (g_application.CurrentFileItem().IsStack())

This comment was marked as spam.

This comment was marked as spam.

jmarshallnz added a commit that referenced this pull request Mar 3, 2014
fixed: Properly handle stacked files for subtitles
@jmarshallnz jmarshallnz merged commit 20fcb22 into xbmc:master Mar 3, 2014
@MartijnKaijser MartijnKaijser modified the milestones: Gotham13.0-alpha12 January 2014, Pending for inclusion Mar 3, 2014
@@ -72,6 +73,8 @@ class CSubtitlesJob: public CJob
virtual bool DoWork()
{
CDirectory::GetDirectory(m_url.Get(), *m_items);
// Sort items by path so they properly order for eg. stacks
m_items->Sort(SortByPath, SortOrderAscending);

This comment was marked as spam.

This comment was marked as spam.

@phate89
Copy link
Contributor

phate89 commented Apr 13, 2014

Is this patch going to allow multiple subtitles even if they are not stacked files? Because there are subtitle services (like itasa that i develope) that sometimes have more than one version in a single zip file and right now i can pass every subtitle but only the first one is considered and there's no way to pass also the 2nd one..

@amet
Copy link
Contributor

amet commented Apr 13, 2014

@arnova

We make sure service sorts it if it's stacked , or let service dictate who should sort. Let service return sorted=true or some such.

Also, we can pass more than one subtitle back to xbmc to handle if movie is stack if it's not stack we only use first one.

@arnova arnova deleted the sub_stack_handling branch November 7, 2014 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants