Permalink
Browse files

CHG: If there is only one movie in a folder, export "movie.nfo", "fol…

…der.jpg" and "fanart.jpg" rather than "<filename>.nfo", "<filename>.tbn" and "<filename>-fanart.jpg" when doing a per-file library export
  • Loading branch information...
1 parent 8d978da commit 18a44cd7a34d82d7fd3f03ad9a6999339c9540fb @koying committed Jul 26, 2012
Showing with 26 additions and 4 deletions.
  1. +26 −4 xbmc/video/VideoDatabase.cpp
@@ -7785,7 +7785,11 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f
progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
// find all movies
- CStdString sql = "select * from movieview";
+ CStdString sql;
+ if (singleFiles)
+ sql = "select movieview.*, countFile from movieview left join (select strPath, count(*) as countFile from path left join files on path.idPath = files.idPath group by path.idPath) as joinSelect on movieview.strPath = joinSelect.strPath;";
+ else
+ sql = "select * from movieview;";
@jmarshallnz
jmarshallnz Jul 26, 2012

This isn't enough. You need to verify the setting on the path. This might be possible without retrieving the scraper settings (GetScraperForPath) by comparing the base path with the video path.

m_pDS->query(sql.c_str());
@@ -7850,6 +7854,10 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f
}
}
+ bool forceDirectoryInfo = false;
+ if (m_pDS->fv("countFile").get_asInt() == 1) // Number of files in the current file's path
+ forceDirectoryInfo = true;
+
CFileItem item(movie.m_strFileNameAndPath,false);
CFileItem saveItem(item);
saveItem.SetArt(artwork);
@@ -7862,7 +7870,11 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f
}
else
{
- CStdString nfoFile(URIUtils::ReplaceExtension(item.GetTBNFile(), ".nfo"));
+ CStdString nfoFile;
+ if (!forceDirectoryInfo)
+ nfoFile = URIUtils::ReplaceExtension(item.GetTBNFile(), ".nfo");
+ else
+ nfoFile = movie.m_strPath + "movie.nfo";
if (item.IsOpticalMediaFile())
{
@@ -7895,11 +7907,21 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f
if (singleFiles && images && !bSkip)
{
- CStdString savedThumb(saveItem.GetTBNFile());
+ CStdString savedThumb;
+ CStdString savedFanart;
+ if (!forceDirectoryInfo)
+ {
+ savedThumb = saveItem.GetTBNFile();
+ savedFanart = URIUtils::ReplaceExtension(savedThumb, "-fanart.jpg");
+ }
+ else
+ {
+ savedThumb = movie.m_strPath + "folder.jpg";
+ savedFanart = movie.m_strPath + "fanart.jpg";
+ }
if (saveItem.HasThumbnail() && (overwrite || !CFile::Exists(savedThumb, false)))
CTextureCache::Get().Export(saveItem.GetThumbnailImage(), savedThumb);
- CStdString savedFanart(URIUtils::ReplaceExtension(savedThumb, "-fanart.jpg"));
if (saveItem.HasProperty("fanart_image") && (overwrite || !CFile::Exists(savedFanart, false)))
CTextureCache::Get().Export(saveItem.GetProperty("fanart_image").asString(), savedFanart);

0 comments on commit 18a44cd

Please sign in to comment.