Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

CHG: refine destination filename when copying from DB

  • Loading branch information...
commit 4aa1bc7885d6a6798f5617cddb5d5bbceb47ed0c 1 parent fb725b7
@koying authored
Showing with 57 additions and 1 deletion.
  1. +57 −1 xbmc/utils/FileOperationJob.cpp
View
58 xbmc/utils/FileOperationJob.cpp
@@ -32,6 +32,9 @@
#include "guilib/LocalizeStrings.h"
#include "guilib/GUIWindowManager.h"
#include "dialogs/GUIDialogExtendedProgressBar.h"
+#include "video/VideoInfoTag.h"
+#include "music/tags/MusicInfoTag.h"
+#include "utils/StringUtils.h"
#ifdef HAS_FILESYSTEM_RAR
#include "filesystem/RarManager.h"
@@ -163,7 +166,7 @@ bool CFileOperationJob::DoProcess(FileAction action, CFileItemList & items, cons
CURL::Decode(strFileName);
// special case for upnp
- if (URIUtils::IsUPnP(items.GetPath()) || URIUtils::IsUPnP(pItem->GetPath()))
+ if ( URIUtils::IsUPnP(items.GetPath()) || URIUtils::IsUPnP(pItem->GetPath()) )
{
// get filename from label instead of path
strFileName = pItem->GetLabel();
@@ -178,6 +181,59 @@ bool CFileOperationJob::DoProcess(FileAction action, CFileItemList & items, cons
strFileName = CUtil::MakeLegalFileName(strFileName);
}
+ // special case for video db
+ if ( URIUtils::IsVideoDb(pItem->GetPath()) )
+ {
+ // Build filename
+ if (pItem->HasVideoInfoTag())
+ {
+ CVideoInfoTag* tag = pItem->GetVideoInfoTag();
+ if (tag->m_type == "movie")
+ {
+ strFileName.Format("%s (%d)", tag->m_strTitle, tag->m_iYear);
+ }
+ else if (tag->m_type == "episode")
+ {
+ strFileName.Format("%s - S%dE%d - %s", tag->m_strShowTitle, tag->m_iSeason, tag->m_iEpisode, tag->m_strTitle);
+ }
+ else if (tag->m_type == "musicvideo")
+ {
+ strFileName = tag->m_strTitle;
+ }
+ }
+ else
+ strFileName = pItem->GetLabel();
+
+ if(!pItem->m_bIsFolder && URIUtils::GetExtension(strFileName).length() == 0)
+ {
+ // FIXME: for now we only work well if the url has the extension
+ // we should map the content type to the extension otherwise
+ strFileName += URIUtils::GetExtension(pItem->GetPath());
+ }
+ strFileName = CUtil::MakeLegalFileName(strFileName);
+ }
+
+ // special case for music db
+ if ( URIUtils::IsMusicDb(pItem->GetPath()) )
+ {
+ // Build filename
+ if (pItem->HasMusicInfoTag())
+ {
+ MUSIC_INFO::CMusicInfoTag* tag = pItem->GetMusicInfoTag();
+ strFileName.Format("%s - %s - %d - %s", StringUtils::Join(tag->m_artist, "+"), tag->m_strAlbum, tag->m_iTrack, tag->m_strTitle);
+ }
+ else
+ strFileName = pItem->GetLabel();
+
+ if(!pItem->m_bIsFolder && URIUtils::GetExtension(strFileName).length() == 0)
+ {
+ // FIXME: for now we only work well if the url has the extension
+ // we should map the content type to the extension otherwise
+ strFileName += URIUtils::GetExtension(pItem->GetPath());
+ }
+ strFileName = CUtil::MakeLegalFileName(strFileName);
+ }
+
CStdString strnewDestFile;
if(!strDestFile.IsEmpty()) // only do this if we have a destination
URIUtils::AddFileToFolder(strDestFile, strFileName, strnewDestFile);
Please sign in to comment.
Something went wrong with that request. Please try again.