Skip to content

Loading…

Fix for downloading subtitles for http videos #4367

Merged
merged 2 commits into from

6 participants

@arnova
Team Kodi member

Should fix problems reported here:

Also improved logging a bit to make spotting issues a little easier and removed the gui setting to configure the custom subtitle path.

@jmarshallnz jmarshallnz commented on an outdated diff
xbmc/video/dialogs/GUIDialogSubtitles.cpp
((6 lines not shown))
CStdString strDownloadPath = "special://temp";
CStdString strDestPath;
std::vector<CStdString> vecFiles;
CStdString strCurrentFilePath = URIUtils::GetDirectory(strCurrentFile);
- if (StringUtils::StartsWith(strCurrentFilePath, "http://"))
+ if (StringUtils::StartsWith(strCurrentFilePath, "http://") && !URIUtils::HasExtension(strCurrentFile, g_advancedSettings.m_videoExtensions))
@jmarshallnz Team Kodi member

Why?? We can't store these on the http server.

@arnova Team Kodi member
arnova added a note

@jmarshallnz : Because afaik this block is only here for streams without an actual filename (/extension). http will be checked once again down below by CUtil::SupportsWriteFileOperations(strCurrentFilePath)). By changing this at least items like http://server/movie.mp4 get their subtitle stored in the custom subtitle folder as eg. movie.srt so it can be reused the next time a user plays the video.

Btw. I think we should drop the http check altogether here and only check the extension.

@jmarshallnz Team Kodi member

Your change would make sense if you dropped to only check extension, yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@amet

Icefilms won't let us

@arnova
Team Kodi member

@amet: Not sure what you mean

@arnova
Team Kodi member

@jmarshallnz : Updated

@amet

@jmarshallnz said "we can't upload to http:" ... It's a joke without a smiley at the end :)

@arnova
Team Kodi member

@amet: Ah yes, you meant: won't let us yet ;-)

@arnova
Team Kodi member

jenkins build this please

@arnova arnova added this to the Gotham13.0-beta2 milestone
@mkorganashvili

When it's going to be merged?

@da-anda
Team Kodi member

as soon as the settings change is resolved

@mkorganashvili

is not it possible to merge only subtitle download fix?!

@da-anda
Team Kodi member

it is if @arnova is splitting up the change to another PR. But this is not really needed, because both fixes have to end up in Gotham anyways - so have patience. And now please stop further non technical/development related questions here on github, because every comment in here will trigger an email notification to ALL XBMC devs - and there already is way to much github spam in our inboxes.

@t-nelson

is not it possible to merge only subtitle download fix?!

Please be patient and trust our judgment. We only use github for development to reduce inbox flooding. Please keep non-technical discussion to the forums in the future.

@jmarshallnz
Team Kodi member

@arnova: Can you please split out the first two commits (improved logging, fix for http:// subs) so we can get those in. I have a feeling the setting thing might take a bit longer than we may want to wait for B2.

@arnova
Team Kodi member

@jmarshallnz : You mean a seperate PR for the rest of the commits?

@arnova
Team Kodi member

@jmarshallnz : Can't we just merge this as a whole? The only remaining issue are the spinner-texts right?

@jmarshallnz
Team Kodi member

A separate PR for the 2 commits I mentioned. The settings removal touches a bunch more code so will take longer to review. It would be nice to get the fixes we know about in so we can push B2 out.

@arnova
Team Kodi member

@jmarshallnz : Will do ASAP. Shouldn't it include arnova@e9e909d as well?

@arnova
Team Kodi member

@jmarshallnz Removed settings commit and moved to seperate PR #4411 . Let me know if you need anything else done.

@jmarshallnz
Team Kodi member

No, it shouldn't include the change from http:// -> unknown extension. That again is something that needs more thought than the simple fix.

@arnova
Team Kodi member

@jmarshallnz : Done, moved the commit to the other PR as well.

@jmarshallnz
Team Kodi member

Thanks! jenkins build this please

@jmarshallnz jmarshallnz added the Gotham label
@jmarshallnz jmarshallnz merged commit 52d498e into xbmc:master

1 check passed

Details default Merged build #369 succeeded in 1 hr 15 min
@jmarshallnz jmarshallnz removed the Gotham label
@arnova arnova deleted the arnova:more_sub_fixes branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 9, 2014
  1. changed: Improve subtitle logging

    arnova committed
Commits on Mar 13, 2014
Showing with 14 additions and 6 deletions.
  1. +14 −6 xbmc/video/dialogs/GUIDialogSubtitles.cpp
View
20 xbmc/video/dialogs/GUIDialogSubtitles.cpp
@@ -414,7 +414,7 @@ void CGUIDialogSubtitles::OnDownloadComplete(const CFileItemList *items, const s
SUBTITLE_STORAGEMODE storageMode = (SUBTITLE_STORAGEMODE) CSettings::Get().GetInt("subtitles.storagemode");
// Get (unstacked) path
- const CStdString &strCurrentFile = g_application.CurrentUnstackedItem().GetPath();
+ CStdString strCurrentFile = g_application.CurrentUnstackedItem().GetPath();
CStdString strDownloadPath = "special://temp";
CStdString strDestPath;
@@ -423,7 +423,9 @@ void CGUIDialogSubtitles::OnDownloadComplete(const CFileItemList *items, const s
CStdString strCurrentFilePath = URIUtils::GetDirectory(strCurrentFile);
if (StringUtils::StartsWith(strCurrentFilePath, "http://"))
{
- vecFiles.push_back("TemporarySubs");
+ strCurrentFilePath = "";
+ strCurrentFile = "TempSubtitle";
+ vecFiles.push_back(strCurrentFile);
}
else
{
@@ -473,18 +475,20 @@ void CGUIDialogSubtitles::OnDownloadComplete(const CFileItemList *items, const s
CStdString strSubExt = URIUtils::GetExtension(strUrl);
CStdString strSubName = StringUtils::Format("%s.%s%s", strFileName.c_str(), strSubLang.c_str(), strSubExt.c_str());
- // Handle URL decoding/slash correction:
+ // Handle URL encoding:
CStdString strDownloadFile = URIUtils::ChangeBasePath(strCurrentFilePath, strSubName, strDownloadPath);
CStdString strDestFile = strDownloadFile;
if (!CFile::Cache(strUrl, strDownloadFile))
{
CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, strSubName, g_localizeStrings.Get(24113));
+ CLog::Log(LOGERROR, "%s - Saving of subtitle %s to %s failed", __FUNCTION__, strUrl.c_str(), strDownloadFile.c_str());
}
else
{
if (strDestPath != strDownloadPath)
{
+ // Handle URL encoding:
CStdString strTryDestFile = URIUtils::ChangeBasePath(strCurrentFilePath, strSubName, strDestPath);
/* Copy the file from temp to our final destination, if that fails fallback to download path
@@ -492,7 +496,7 @@ void CGUIDialogSubtitles::OnDownloadComplete(const CFileItemList *items, const s
* so that all remaining items (including the .idx below) are copied directly to their final destination and thus all
* items end up in the same folder
*/
- CLog::Log(LOGDEBUG, "%s - Saving subtitle %s to %s", __FUNCTION__, strDownloadFile.c_str(), strDestPath.c_str());
+ CLog::Log(LOGDEBUG, "%s - Saving subtitle %s to %s", __FUNCTION__, strDownloadFile.c_str(), strTryDestFile.c_str());
if (CFile::Cache(strDownloadFile, strTryDestFile))
{
CFile::Delete(strDownloadFile);
@@ -501,10 +505,14 @@ void CGUIDialogSubtitles::OnDownloadComplete(const CFileItemList *items, const s
}
else
{
- CLog::Log(LOGWARNING, "%s - Saving of subtitle %s to %s failed. Falling back to %s", __FUNCTION__, strDownloadFile.c_str(), strDestPath.c_str(), strDownloadPath.c_str());
+ CLog::Log(LOGWARNING, "%s - Saving of subtitle %s to %s failed. Falling back to %s", __FUNCTION__, strDownloadFile.c_str(), strTryDestFile.c_str(), strDownloadPath.c_str());
strDestPath = strDownloadPath; // Copy failed, use fallback for the rest of the items
}
}
+ else
+ {
+ CLog::Log(LOGDEBUG, "%s - Saved subtitle %s to %s", __FUNCTION__, strUrl.c_str(), strDownloadFile.c_str());
+ }
// for ".sub" subtitles we check if ".idx" counterpart exists and copy that as well
if (strSubExt.Equals(".sub"))
@@ -513,7 +521,7 @@ void CGUIDialogSubtitles::OnDownloadComplete(const CFileItemList *items, const s
if(CFile::Exists(strUrl))
{
CStdString strSubNameIdx = StringUtils::Format("%s.%s.idx", strFileName.c_str(), strSubLang.c_str());
- // Handle URL decoding/slash correction:
+ // Handle URL encoding:
strDestFile = URIUtils::ChangeBasePath(strCurrentFilePath, strSubNameIdx, strDestPath);
CFile::Cache(strUrl, strDestFile);
}
Something went wrong with that request. Please try again.