Skip to content

Commit

Permalink
fixed: Downloading subtitles for http sources was broken
Browse files Browse the repository at this point in the history
  • Loading branch information
arnova committed Mar 13, 2014
1 parent 2f6935c commit 2044a60
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions xbmc/video/dialogs/GUIDialogSubtitles.cpp
Expand Up @@ -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;
Expand All @@ -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
{
Expand Down Expand Up @@ -473,7 +475,7 @@ 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;

Expand All @@ -486,6 +488,7 @@ void CGUIDialogSubtitles::OnDownloadComplete(const CFileItemList *items, const s
{
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
Expand Down Expand Up @@ -518,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);
}
Expand Down

0 comments on commit 2044a60

Please sign in to comment.