Skip to content

Commit

Permalink
CHG: Add extension to videodb url's
Browse files Browse the repository at this point in the history
  • Loading branch information
koying committed Oct 9, 2012
1 parent b481a54 commit fb725b7
Showing 1 changed file with 39 additions and 38 deletions.
77 changes: 39 additions & 38 deletions xbmc/video/VideoDatabase.cpp
Expand Up @@ -5686,7 +5686,9 @@ bool CVideoDatabase::GetMoviesByWhere(const CStdString& strBaseDir, const Filter
CFileItemPtr pItem(new CFileItem(movie)); CFileItemPtr pItem(new CFileItem(movie));


CVideoDbUrl itemUrl = videoUrl; CVideoDbUrl itemUrl = videoUrl;
CStdString path; path.Format("%ld", movie.m_iDbId); CStdString strFileName = record->at(VIDEODB_DETAILS_MOVIE_FILE).get_asString();
CStdString strExt = URIUtils::GetExtension(strFileName);
CStdString path; path.Format("%ld%s", movie.m_iDbId,strExt.c_str());
itemUrl.AppendPath(path); itemUrl.AppendPath(path);
pItem->SetPath(itemUrl.ToString()); pItem->SetPath(itemUrl.ToString());


Expand Down Expand Up @@ -6105,11 +6107,13 @@ bool CVideoDatabase::GetEpisodesByWhere(const CStdString& strBaseDir, const Filt
int idEpisode = record->at(0).get_asInt(); int idEpisode = record->at(0).get_asInt();


CVideoDbUrl itemUrl = videoUrl; CVideoDbUrl itemUrl = videoUrl;
CStdString strFileName = record->at(VIDEODB_DETAILS_EPISODE_FILE).get_asString();
CStdString strExt = URIUtils::GetExtension(strFileName);
CStdString path; CStdString path;
if (appendFullShowPath) if (appendFullShowPath)
path.Format("%ld/%ld/%ld", record->at(VIDEODB_DETAILS_EPISODE_TVSHOW_ID).get_asInt(), movie.m_iSeason, idEpisode); path.Format("%ld/%ld/%ld%s", record->at(VIDEODB_DETAILS_EPISODE_TVSHOW_ID).get_asInt(), movie.m_iSeason, idEpisode, strExt.c_str());
else else
path.Format("%ld", idEpisode); path.Format("%ld%s", idEpisode, strExt.c_str());
itemUrl.AppendPath(path); itemUrl.AppendPath(path);
pItem->SetPath(itemUrl.ToString()); pItem->SetPath(itemUrl.ToString());


Expand Down Expand Up @@ -6859,10 +6863,7 @@ void CVideoDatabase::GetMusicVideosByAlbum(const CStdString& strSearch, CFileIte
if (NULL == m_pDB.get()) return; if (NULL == m_pDB.get()) return;
if (NULL == m_pDS.get()) return; if (NULL == m_pDS.get()) return;


if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) strSQL = PrepareSQL("select musicvideo.idMVideo,musicvideo.c%02d,musicvideo.c%02d,path.strPath,files.strFilename from musicvideo,files,path where files.idFile=musicvideo.idFile and files.idPath=path.idPath and musicvideo.c%02d like '%%%s%%'",VIDEODB_ID_MUSICVIDEO_ALBUM,VIDEODB_ID_MUSICVIDEO_TITLE,VIDEODB_ID_MUSICVIDEO_ALBUM,strSearch.c_str());
strSQL = PrepareSQL("select musicvideo.idMVideo,musicvideo.c%02d,musicvideo.c%02d,path.strPath from musicvideo,files,path where files.idFile=musicvideo.idFile and files.idPath=path.idPath and musicvideo.c%02d like '%%%s%%'",VIDEODB_ID_MUSICVIDEO_ALBUM,VIDEODB_ID_MUSICVIDEO_TITLE,VIDEODB_ID_MUSICVIDEO_ALBUM,strSearch.c_str());
else
strSQL = PrepareSQL("select musicvideo.idMVideo,musicvideo.c%02d,musicvideo.c%02d from musicvideo where musicvideo.c%02d like '%%%s%%'",VIDEODB_ID_MUSICVIDEO_ALBUM,VIDEODB_ID_MUSICVIDEO_TITLE,VIDEODB_ID_MUSICVIDEO_ALBUM,strSearch.c_str());
m_pDS->query( strSQL.c_str() ); m_pDS->query( strSQL.c_str() );


while (!m_pDS->eof()) while (!m_pDS->eof())
Expand All @@ -6875,8 +6876,10 @@ void CVideoDatabase::GetMusicVideosByAlbum(const CStdString& strSearch, CFileIte
} }


CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString()+" - "+m_pDS->fv(2).get_asString())); CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString()+" - "+m_pDS->fv(2).get_asString()));
CStdString strFileName = m_pDS->fv("files.strFilename").get_asString();
CStdString strExt = URIUtils::GetExtension(strFileName);
CStdString strDir; CStdString strDir;
strDir.Format("3/2/%ld",m_pDS->fv("musicvideo.idMVideo").get_asInt()); strDir.Format("3/2/%ld%s",m_pDS->fv("musicvideo.idMVideo").get_asInt(),strExt.c_str());


pItem->SetPath("videodb://"+ strDir); pItem->SetPath("videodb://"+ strDir);
pItem->m_bIsFolder=false; pItem->m_bIsFolder=false;
Expand Down Expand Up @@ -6949,9 +6952,11 @@ bool CVideoDatabase::GetMusicVideosByWhere(const CStdString &baseDir, const Filt
g_passwordManager.IsDatabasePathUnlocked(musicvideo.m_strPath, g_settings.m_videoSources)) g_passwordManager.IsDatabasePathUnlocked(musicvideo.m_strPath, g_settings.m_videoSources))
{ {
CFileItemPtr item(new CFileItem(musicvideo)); CFileItemPtr item(new CFileItem(musicvideo));
CStdString strFileName = record->at(VIDEODB_DETAILS_MUSICVIDEO_FILE).get_asString();
CStdString strExt = URIUtils::GetExtension(strFileName);


CVideoDbUrl itemUrl = videoUrl; CVideoDbUrl itemUrl = videoUrl;
CStdString path; path.Format("%ld", record->at(0).get_asInt()); CStdString path; path.Format("%ld%s", record->at(0).get_asInt(), strExt.c_str());
itemUrl.AppendPath(path); itemUrl.AppendPath(path);
item->SetPath(itemUrl.ToString()); item->SetPath(itemUrl.ToString());


Expand Down Expand Up @@ -7030,7 +7035,9 @@ bool CVideoDatabase::GetRandomMusicVideo(CFileItem* item, int& idSong, const CSt
return false; return false;
} }
*item->GetVideoInfoTag() = GetDetailsForMusicVideo(m_pDS); *item->GetVideoInfoTag() = GetDetailsForMusicVideo(m_pDS);
CStdString path; path.Format("videodb://3/2/%ld",item->GetVideoInfoTag()->m_iDbId); CStdString strFileName = m_pDS->fv("strFilename").get_asString();
CStdString strExt = URIUtils::GetExtension(strFileName);
CStdString path; path.Format("videodb://3/2/%ld%s",item->GetVideoInfoTag()->m_iDbId,strExt.c_str());
item->SetPath(path); item->SetPath(path);
idSong = m_pDS->fv("idMVideo").get_asInt(); idSong = m_pDS->fv("idMVideo").get_asInt();
item->SetLabel(item->GetVideoInfoTag()->m_strTitle); item->SetLabel(item->GetVideoInfoTag()->m_strTitle);
Expand Down Expand Up @@ -7098,10 +7105,7 @@ void CVideoDatabase::GetMoviesByName(const CStdString& strSearch, CFileItemList&
if (NULL == m_pDB.get()) return; if (NULL == m_pDB.get()) return;
if (NULL == m_pDS.get()) return; if (NULL == m_pDS.get()) return;


if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) strSQL = PrepareSQL("select movie.idMovie,movie.c%02d,path.strPath,files.strFilename, movie.idSet from movie,files,path where files.idFile=movie.idFile and files.idPath=path.idPath and movie.c%02d like '%%%s%%'",VIDEODB_ID_TITLE,VIDEODB_ID_TITLE,strSearch.c_str());
strSQL = PrepareSQL("select movie.idMovie,movie.c%02d,path.strPath, movie.idSet from movie,files,path where files.idFile=movie.idFile and files.idPath=path.idPath and movie.c%02d like '%%%s%%'",VIDEODB_ID_TITLE,VIDEODB_ID_TITLE,strSearch.c_str());
else
strSQL = PrepareSQL("select movie.idMovie,movie.c%02d, movie.idSet from movie where movie.c%02d like '%%%s%%'",VIDEODB_ID_TITLE,VIDEODB_ID_TITLE,strSearch.c_str());
m_pDS->query( strSQL.c_str() ); m_pDS->query( strSQL.c_str() );


while (!m_pDS->eof()) while (!m_pDS->eof())
Expand All @@ -7117,10 +7121,12 @@ void CVideoDatabase::GetMoviesByName(const CStdString& strSearch, CFileItemList&
int setId = m_pDS->fv("movie.idSet").get_asInt(); int setId = m_pDS->fv("movie.idSet").get_asInt();
CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString())); CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString()));
CStdString path; CStdString path;
if (setId <= 0) CStdString strFileName = m_pDS->fv("files.strFilename").get_asString();
path.Format("videodb://1/2/%i", movieId); CStdString strExt = URIUtils::GetExtension(strFileName);
if (setId <= 0)
path.Format("videodb://1/2/%i%s", movieId, strExt.c_str());
else else
path.Format("videodb://1/7/%i/%i", setId, movieId); path.Format("videodb://1/7/%i/%i%s", setId, movieId, strExt.c_str());
pItem->SetPath(path); pItem->SetPath(path);
pItem->m_bIsFolder=false; pItem->m_bIsFolder=false;
items.Add(pItem); items.Add(pItem);
Expand Down Expand Up @@ -7185,10 +7191,7 @@ void CVideoDatabase::GetEpisodesByName(const CStdString& strSearch, CFileItemLis
if (NULL == m_pDB.get()) return; if (NULL == m_pDB.get()) return;
if (NULL == m_pDS.get()) return; if (NULL == m_pDS.get()) return;


if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) strSQL = PrepareSQL("select episode.idEpisode,episode.c%02d,episode.c%02d,episode.idShow,tvshow.c%02d,path.strPath,files.strFilename from episode,files,path,tvshow where files.idFile=episode.idFile and episode.idShow=tvshow.idShow and files.idPath=path.idPath and episode.c%02d like '%%%s%%'",VIDEODB_ID_EPISODE_TITLE,VIDEODB_ID_EPISODE_SEASON,VIDEODB_ID_TV_TITLE,VIDEODB_ID_EPISODE_TITLE,strSearch.c_str());
strSQL = PrepareSQL("select episode.idEpisode,episode.c%02d,episode.c%02d,episode.idShow,tvshow.c%02d,path.strPath from episode,files,path,tvshow where files.idFile=episode.idFile and episode.idShow=tvshow.idShow and files.idPath=path.idPath and episode.c%02d like '%%%s%%'",VIDEODB_ID_EPISODE_TITLE,VIDEODB_ID_EPISODE_SEASON,VIDEODB_ID_TV_TITLE,VIDEODB_ID_EPISODE_TITLE,strSearch.c_str());
else
strSQL = PrepareSQL("select episode.idEpisode,episode.c%02d,episode.c%02d,episode.idShow,tvshow.c%02d from episode,tvshow where tvshow.idShow=episode.idShow and episode.c%02d like '%%%s%%'",VIDEODB_ID_EPISODE_TITLE,VIDEODB_ID_EPISODE_SEASON,VIDEODB_ID_TV_TITLE,VIDEODB_ID_EPISODE_TITLE,strSearch.c_str());
m_pDS->query( strSQL.c_str() ); m_pDS->query( strSQL.c_str() );


while (!m_pDS->eof()) while (!m_pDS->eof())
Expand All @@ -7201,7 +7204,9 @@ void CVideoDatabase::GetEpisodesByName(const CStdString& strSearch, CFileItemLis
} }


CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString()+" ("+m_pDS->fv(4).get_asString()+")")); CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString()+" ("+m_pDS->fv(4).get_asString()+")"));
CStdString path; path.Format("videodb://2/2/%ld/%ld/%ld",m_pDS->fv("episode.idShow").get_asInt(),m_pDS->fv(2).get_asInt(),m_pDS->fv(0).get_asInt()); CStdString strFileName = m_pDS->fv("files.strFilename").get_asString();
CStdString strExt = URIUtils::GetExtension(strFileName);
CStdString path; path.Format("videodb://2/2/%ld/%ld/%ld%s",m_pDS->fv("episode.idShow").get_asInt(),m_pDS->fv(2).get_asInt(),m_pDS->fv(0).get_asInt(),strExt.c_str());
pItem->SetPath(path); pItem->SetPath(path);
pItem->m_bIsFolder=false; pItem->m_bIsFolder=false;
items.Add(pItem); items.Add(pItem);
Expand All @@ -7228,10 +7233,7 @@ void CVideoDatabase::GetMusicVideosByName(const CStdString& strSearch, CFileItem
if (NULL == m_pDB.get()) return; if (NULL == m_pDB.get()) return;
if (NULL == m_pDS.get()) return; if (NULL == m_pDS.get()) return;


if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) strSQL = PrepareSQL("select musicvideo.idMVideo,musicvideo.c%02d,path.strPath,files.strFilename from musicvideo,files,path where files.idFile=musicvideo.idFile and files.idPath=path.idPath and musicvideo.c%02d like '%%%s%%'",VIDEODB_ID_MUSICVIDEO_TITLE,VIDEODB_ID_MUSICVIDEO_TITLE,strSearch.c_str());
strSQL = PrepareSQL("select musicvideo.idMVideo,musicvideo.c%02d,path.strPath from musicvideo,files,path where files.idFile=musicvideo.idFile and files.idPath=path.idPath and musicvideo.c%02d like '%%%s%%'",VIDEODB_ID_MUSICVIDEO_TITLE,VIDEODB_ID_MUSICVIDEO_TITLE,strSearch.c_str());
else
strSQL = PrepareSQL("select musicvideo.idMVideo,musicvideo.c%02d from musicvideo where musicvideo.c%02d like '%%%s%%'",VIDEODB_ID_MUSICVIDEO_TITLE,VIDEODB_ID_MUSICVIDEO_TITLE,strSearch.c_str());
m_pDS->query( strSQL.c_str() ); m_pDS->query( strSQL.c_str() );


while (!m_pDS->eof()) while (!m_pDS->eof())
Expand All @@ -7244,8 +7246,10 @@ void CVideoDatabase::GetMusicVideosByName(const CStdString& strSearch, CFileItem
} }


CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString())); CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString()));
CStdString strFileName = m_pDS->fv("files.strFilename").get_asString();
CStdString strExt = URIUtils::GetExtension(strFileName);
CStdString strDir; CStdString strDir;
strDir.Format("3/2/%ld",m_pDS->fv("musicvideo.idMVideo").get_asInt()); strDir.Format("3/2/%ld%s",m_pDS->fv("musicvideo.idMVideo").get_asInt(),strExt.c_str());


pItem->SetPath("videodb://"+ strDir); pItem->SetPath("videodb://"+ strDir);
pItem->m_bIsFolder=false; pItem->m_bIsFolder=false;
Expand Down Expand Up @@ -7276,10 +7280,7 @@ void CVideoDatabase::GetEpisodesByPlot(const CStdString& strSearch, CFileItemLis
if (NULL == m_pDB.get()) return; if (NULL == m_pDB.get()) return;
if (NULL == m_pDS.get()) return; if (NULL == m_pDS.get()) return;


if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) strSQL = PrepareSQL("select episode.idEpisode,episode.c%02d,episode.c%02d,episode.idShow,tvshow.c%02d,path.strPath,files.strFilename from episode,files,path,tvshow where files.idFile=episode.idFile and files.idPath=path.idPath and tvshow.idShow=episode.idShow and episode.c%02d like '%%%s%%'",VIDEODB_ID_EPISODE_TITLE,VIDEODB_ID_EPISODE_SEASON,VIDEODB_ID_TV_TITLE,VIDEODB_ID_EPISODE_PLOT,strSearch.c_str());
strSQL = PrepareSQL("select episode.idEpisode,episode.c%02d,episode.c%02d,episode.idShow,tvshow.c%02d,path.strPath from episode,files,path,tvshow where files.idFile=episode.idFile and files.idPath=path.idPath and tvshow.idShow=episode.idShow and episode.c%02d like '%%%s%%'",VIDEODB_ID_EPISODE_TITLE,VIDEODB_ID_EPISODE_SEASON,VIDEODB_ID_TV_TITLE,VIDEODB_ID_EPISODE_PLOT,strSearch.c_str());
else
strSQL = PrepareSQL("select episode.idEpisode,episode.c%02d,episode.c%02d,episode.idShow,tvshow.c%02d from episode,tvshow where tvshow.idShow=episode.idShow and episode.c%02d like '%%%s%%'",VIDEODB_ID_EPISODE_TITLE,VIDEODB_ID_EPISODE_SEASON,VIDEODB_ID_TV_TITLE,VIDEODB_ID_EPISODE_PLOT,strSearch.c_str());
m_pDS->query( strSQL.c_str() ); m_pDS->query( strSQL.c_str() );


while (!m_pDS->eof()) while (!m_pDS->eof())
Expand All @@ -7292,7 +7293,9 @@ void CVideoDatabase::GetEpisodesByPlot(const CStdString& strSearch, CFileItemLis
} }


CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString()+" ("+m_pDS->fv(4).get_asString()+")")); CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString()+" ("+m_pDS->fv(4).get_asString()+")"));
CStdString path; path.Format("videodb://2/2/%ld/%ld/%ld",m_pDS->fv("episode.idShow").get_asInt(),m_pDS->fv(2).get_asInt(),m_pDS->fv(0).get_asInt()); CStdString strFileName = m_pDS->fv("files.strFilename").get_asString();
CStdString strExt = URIUtils::GetExtension(strFileName);
CStdString path; path.Format("videodb://2/2/%ld/%ld/%ld%s",m_pDS->fv("episode.idShow").get_asInt(),m_pDS->fv(2).get_asInt(),m_pDS->fv(0).get_asInt(),strExt.c_str());
pItem->SetPath(path); pItem->SetPath(path);
pItem->m_bIsFolder=false; pItem->m_bIsFolder=false;
items.Add(pItem); items.Add(pItem);
Expand All @@ -7315,11 +7318,7 @@ void CVideoDatabase::GetMoviesByPlot(const CStdString& strSearch, CFileItemList&
if (NULL == m_pDB.get()) return; if (NULL == m_pDB.get()) return;
if (NULL == m_pDS.get()) return; if (NULL == m_pDS.get()) return;


if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) strSQL = PrepareSQL("select movie.idMovie, movie.c%02d, path.strPath, files.strFilename from movie,files,path where files.idFile=movie.idFile and files.idPath=path.idPath and (movie.c%02d like '%%%s%%' or movie.c%02d like '%%%s%%' or movie.c%02d like '%%%s%%')",VIDEODB_ID_TITLE,VIDEODB_ID_PLOT,strSearch.c_str(),VIDEODB_ID_PLOTOUTLINE,strSearch.c_str(),VIDEODB_ID_TAGLINE,strSearch.c_str());
strSQL = PrepareSQL("select movie.idMovie, movie.c%02d, path.strPath from movie,files,path where files.idFile=movie.idFile and files.idPath=path.idPath and (movie.c%02d like '%%%s%%' or movie.c%02d like '%%%s%%' or movie.c%02d like '%%%s%%')",VIDEODB_ID_TITLE,VIDEODB_ID_PLOT,strSearch.c_str(),VIDEODB_ID_PLOTOUTLINE,strSearch.c_str(),VIDEODB_ID_TAGLINE,strSearch.c_str());
else
strSQL = PrepareSQL("select movie.idMovie, movie.c%02d from movie where (movie.c%02d like '%%%s%%' or movie.c%02d like '%%%s%%' or movie.c%02d like '%%%s%%')",VIDEODB_ID_TITLE,VIDEODB_ID_PLOT,strSearch.c_str(),VIDEODB_ID_PLOTOUTLINE,strSearch.c_str(),VIDEODB_ID_TAGLINE,strSearch.c_str());

m_pDS->query( strSQL.c_str() ); m_pDS->query( strSQL.c_str() );


while (!m_pDS->eof()) while (!m_pDS->eof())
Expand All @@ -7332,7 +7331,9 @@ void CVideoDatabase::GetMoviesByPlot(const CStdString& strSearch, CFileItemList&
} }


CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString())); CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString()));
CStdString path; path.Format("videodb://1/2/%ld", m_pDS->fv(0).get_asInt()); CStdString strFileName = m_pDS->fv("files.strFilename").get_asString();
CStdString strExt = URIUtils::GetExtension(strFileName);
CStdString path; path.Format("videodb://1/2/%ld%s", m_pDS->fv(0).get_asInt(),strExt.c_str());
pItem->SetPath(path); pItem->SetPath(path);
pItem->m_bIsFolder=false; pItem->m_bIsFolder=false;


Expand Down

0 comments on commit fb725b7

Please sign in to comment.