before_code stringlengths 14 465k | reviewer_comment stringlengths 16 64.5k | after_code stringlengths 9 467k | diff_context stringlengths 0 97k | file_path stringlengths 5 226 | comment_line int32 0 26 | language stringclasses 37
values | quality_score float32 0.07 1 | comment_type stringclasses 9
values | comment_length int32 16 64.5k | before_lines int32 1 17.2k | after_lines int32 1 12.1k | is_negative bool 2
classes | pr_title stringlengths 1 308 | pr_number int32 1 299k | repo_name stringclasses 533
values | repo_stars int64 321 419k | repo_language stringclasses 27
values | reviewer_username stringlengths 0 39 | author_username stringlengths 2 39 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
/* In shared mode Windows tells us what format the audio must be in. */
/* Beginning of suspicous code
*
* Is this seemingly unnecessary activation actually needed in some cases to initialize
* PKEY_AudioEngine_DeviceFormat? Or was it forgotten when GetMixFormat() was commented?
* Found a b... | ```suggestion
WAVEFORMATEX* pwfx = reinterpret_cast<WAVEFORMATEX*>(varName.blob.pBlobData);
``` | /* In shared mode Windows tells us what format the audio must be in. */
hr = pProperty->GetValue(PKEY_AudioEngine_DeviceFormat, &varName);
if (SUCCEEDED(hr) && varName.blob.cbSize >= sizeof(WAVEFORMATEX))
{
// This may be a WAVEFORMATEXTENSIBLE but the extra data is not needed.
WAVEFORMATEX*... | @@ -85,33 +85,66 @@ std::vector<RendererDetail> CAESinkFactoryWin::GetRendererDetails()
PropVariantInit(&varName);
hr = pEnumDevices->Item(i, pDevice.GetAddressOf());
- EXIT_ON_FAILURE(hr, "Retrieval of WASAPI endpoint failed.")
+ EXIT_ON_FAILURE(hr, "Retrieval of endpoint failed.")
hr = pDevic... | xbmc/cores/AudioEngine/Sinks/windows/AESinkFactoryWin32.cpp | 26 | C++ | 1 | suggestion | 103 | 51 | 51 | false | [Windows] Refactor Directsound Device Default and Enumeration | 26,174 | xbmc/xbmc | 17,740 | C++ | thexai | CrystalP |
hr = pProperty->GetValue(PKEY_AudioEndpoint_GUID, &varName);
EXIT_ON_FAILURE(hr, "Retrieval of endpoint GUID failed.")
details.strDeviceId = KODI::PLATFORM::WINDOWS::FromW(varName.pwszVal);
PropVariantClear(&varName);
hr = pProperty->GetValue(PKEY_AudioEndpoint_FormFactor, &varName);
EXIT_ON_... | Maybe not treat as error and provide fallback:
change LOGERROR to LOGDEBUG and use as fallback
```
details.nChannels = 2;
details.m_samplesPerSec = 48000;
```
Anyway is no EXIT_ON_FAILURE here.
Then in `EnumerateDevicesEx` remove if conditions `if (detail.nChannels)`, etc.
|
hr = pProperty->GetValue(PKEY_AudioEndpoint_GUID, &varName);
EXIT_ON_FAILURE(hr, "Retrieval of endpoint GUID failed.")
details.strDeviceId = KODI::PLATFORM::WINDOWS::FromW(varName.pwszVal);
PropVariantClear(&varName);
hr = pProperty->GetValue(PKEY_AudioEndpoint_FormFactor, &varName);
EXIT_ON_... | @@ -85,33 +85,47 @@ std::vector<RendererDetail> CAESinkFactoryWin::GetRendererDetails()
PropVariantInit(&varName);
hr = pEnumDevices->Item(i, pDevice.GetAddressOf());
- EXIT_ON_FAILURE(hr, "Retrieval of WASAPI endpoint failed.")
+ EXIT_ON_FAILURE(hr, "Retrieval of endpoint failed.")
hr = pDevic... | xbmc/cores/AudioEngine/Sinks/windows/AESinkFactoryWin32.cpp | 26 | C++ | 1 | bug | 290 | 51 | 51 | false | [Windows] Refactor Directsound Device Default and Enumeration | 26,174 | xbmc/xbmc | 17,740 | C++ | thexai | CrystalP |
unsigned int validBitsPerSample;
AEDataFormat subFormatType;
};
//! @todo
//! Sample formats go from float -> 32 bit int -> 24 bit int (packed in 32) -> -> 24 bit int -> 16 bit int */
//! versions of Kodi before 14.0 had a bug which made S24NE4MSB the first format selected
//! this bug worked around some driver bu... | Maybe keep `bool bDefault;` last member of struct (move one line up) | unsigned int validBitsPerSample;
AEDataFormat subFormatType;
};
//! @todo
//! Sample formats go from float -> 32 bit int -> 24 bit int (packed in 32) -> -> 24 bit int -> 16 bit int */
//! versions of Kodi before 14.0 had a bug which made S24NE4MSB the first format selected
//! this bug worked around some driver bu... | @@ -183,6 +183,7 @@ struct RendererDetail
unsigned int nChannels;
unsigned int uiChannelMask;
bool bDefault;
+ unsigned long m_samplesPerSec; //!< Sample rate of the system default format | xbmc/cores/AudioEngine/Sinks/windows/AESinkFactoryWin.h | 26 | C/C++ | 0.571 | suggestion | 68 | 51 | 51 | false | [Windows] Refactor Directsound Device Default and Enumeration | 26,174 | xbmc/xbmc | 17,740 | C++ | thexai | CrystalP |
/* Make sure we know how much data is in the cache */
if (!UpdateCacheStatus())
m_isDirtyDS = true;
/** returns current cached data duration in seconds */
status.SetDelay((double)m_CacheLen / (double)m_AvgBytesPerSec);
}
double CAESinkDirectSound::GetCacheTotal()
{
/** returns total cache capacity in se... | Blank line to separate if (detail.eDeviceType != AE_DEVTYPE_PCM) bloc
Also blank line after end of bloc. | status.SetDelay((double)m_CacheLen / (double)m_AvgBytesPerSec);
}
double CAESinkDirectSound::GetCacheTotal()
{
/** returns total cache capacity in seconds */
return (double)m_dwBufferLen / (double)m_AvgBytesPerSec;
}
void CAESinkDirectSound::EnumerateDevicesEx(AEDeviceInfoList &deviceInfoList, bool force)
{
C... | @@ -451,122 +424,41 @@ double CAESinkDirectSound::GetCacheTotal()
void CAESinkDirectSound::EnumerateDevicesEx(AEDeviceInfoList &deviceInfoList, bool force)
{
- CAEDeviceInfo deviceInfo;
+ CAEDeviceInfo deviceInfo{};
- ComPtr<IMMDeviceEnumerator> pEnumerator = nullptr;
- ComPtr<IMMDeviceCollection> pEnu... | xbmc/cores/AudioEngine/Sinks/AESinkDirectSound.cpp | 26 | C++ | 0.571 | style | 108 | 51 | 51 | false | [Windows] Refactor Directsound Device Default and Enumeration | 26,174 | xbmc/xbmc | 17,740 | C++ | thexai | CrystalP |
}
void CAESinkDirectSound::Register()
{
AE::AESinkRegEntry reg;
reg.sinkName = "DIRECTSOUND";
reg.createFunc = CAESinkDirectSound::Create;
reg.enumerateFunc = CAESinkDirectSound::EnumerateDevicesEx;
AE::CAESinkFactory::RegisterSink(reg);
}
std::unique_ptr<IAESink> CAESinkDirectSound::Create(std::string& dev... | Not seems necessary initialize with "unknown" as this value never will be displayed (in normal circumstances). | reg.sinkName = "DIRECTSOUND";
reg.createFunc = CAESinkDirectSound::Create;
reg.enumerateFunc = CAESinkDirectSound::EnumerateDevicesEx;
AE::CAESinkFactory::RegisterSink(reg);
}
std::unique_ptr<IAESink> CAESinkDirectSound::Create(std::string& device,
AEAudioFor... | @@ -119,56 +104,42 @@ std::unique_ptr<IAESink> CAESinkDirectSound::Create(std::string& device,
return {};
}
-bool CAESinkDirectSound::Initialize(AEAudioFormat &format, std::string &device)
+bool CAESinkDirectSound::Initialize(AEAudioFormat& format, std::string& device)
{
if (m_initialized)
return false;
... | xbmc/cores/AudioEngine/Sinks/AESinkDirectSound.cpp | 26 | C++ | 0.286 | suggestion | 110 | 51 | 51 | false | [Windows] Refactor Directsound Device Default and Enumeration | 26,174 | xbmc/xbmc | 17,740 | C++ | thexai | CrystalP |
if (StringUtils::CompareNoCase(detail.strDeviceId, strDeviceGUID) != 0)
continue;
if (detail.strDeviceEnumerator == "BTHENUM")
{
deviceIsBluetooth = true;
CLog::LogF(LOGDEBUG, "Audio device '{}' is detected as Bluetooth device", deviceFriendlyName);
}
deviceFriendlyName = detail.... | Now `#include <Rpc.h>` and `#pragma comment(lib, "Rpcrt4.lib")` lines can be removed. | deviceIsBluetooth = true;
CLog::LogF(LOGDEBUG, "Audio device '{}' is detected as Bluetooth device", deviceFriendlyName);
}
deviceFriendlyName = detail.strDescription;
break;
}
hr = DirectSoundCreate(&deviceGUID, m_pDSound.ReleaseAndGetAddressOf(), nullptr);
if (FAILED(hr))
{
CLog... | @@ -119,56 +104,42 @@ std::unique_ptr<IAESink> CAESinkDirectSound::Create(std::string& device,
return {};
}
-bool CAESinkDirectSound::Initialize(AEAudioFormat &format, std::string &device)
+bool CAESinkDirectSound::Initialize(AEAudioFormat& format, std::string& device)
{
if (m_initialized)
return false;
... | xbmc/cores/AudioEngine/Sinks/AESinkDirectSound.cpp | 26 | C++ | 0.571 | suggestion | 85 | 51 | 51 | false | [Windows] Refactor Directsound Device Default and Enumeration | 26,174 | xbmc/xbmc | 17,740 | C++ | thexai | CrystalP |
#define XINPUT_IR_REMOTE_LIVE_TV 24
#define XINPUT_IR_REMOTE_STAR 40
#define XINPUT_IR_REMOTE_HASH 41
#define XINPUT_IR_REMOTE_CLEAR 249
// additional keys not defined by xbox remotes but present on generic remotes
#define XINPUT_IR_REMOTE_TELETEXT 250
#define XINPUT_IR_REMOTE_RED 251
#define XINPUT_IR_REMOTE_GREEN 25... | Is there any existing documentation for the favorite menu button for context? Same for "last". | #define XINPUT_IR_REMOTE_LIVE_TV 24
#define XINPUT_IR_REMOTE_STAR 40
#define XINPUT_IR_REMOTE_HASH 41
#define XINPUT_IR_REMOTE_CLEAR 249
// additional keys not defined by xbox remotes but present on generic remotes
#define XINPUT_IR_REMOTE_TELETEXT 250
#define XINPUT_IR_REMOTE_RED 251
#define XINPUT_IR_REMOTE_GREEN 25... | @@ -86,6 +86,9 @@
#define XINPUT_IR_REMOTE_PRINT 240
+#define XINPUT_IR_REMOTE_FAVORITE_MENU 241 | xbmc/input/remote/IRRemote.h | 26 | C/C++ | 0.143 | suggestion | 94 | 29 | 32 | false | [input/remote] Add buttons "favorites" and "last" | 26,181 | xbmc/xbmc | 17,740 | C++ | garbear | bonzini |
g_passwordManager.bMasterUser)
{
return true;
}
const std::string& strHeading = g_localizeStrings.Get(iHeading);
int iVerifyPasswordResult = VerifyPassword(btnType, strPassword, strHeading);
if (iVerifyPasswordResult == -1)
bCanceled = true;
return (iVerifyPasswordResult==0);
}
bool CGUIPa... | why not use int? enums are int by default
```suggestion
if (static_cast<int>(lockLevel) - 1 <= static_cast<int>(CViewStateSettings::GetInstance().GetSettingLevel()) &&
```
also others on below code | g_passwordManager.bMasterUser)
{
return true;
}
const std::string& strHeading = g_localizeStrings.Get(iHeading);
int iVerifyPasswordResult = VerifyPassword(btnType, strPassword, strHeading);
if (iVerifyPasswordResult == -1)
bCanceled = true;
return (iVerifyPasswordResult==0);
}
bool CGUIPa... | @@ -377,29 +377,29 @@ bool CGUIPassword::CheckSettingLevelLock(const SettingLevel& level, bool enforce
{
const std::shared_ptr<CProfileManager> profileManager = CServiceBroker::GetSettingsComponent()->GetProfileManager();
- LOCK_LEVEL::SETTINGS_LOCK lockLevel = profileManager->GetCurrentProfile().settingsLockLev... | xbmc/GUIPassword.cpp | 26 | C++ | 1 | question | 205 | 51 | 51 | false | SettingsLock: convert to enum class | 26,189 | xbmc/xbmc | 17,740 | C++ | CastagnaIT | notspiff |
g_charsetConverter.ToUtf8(m_fileCharset, str, ret);
std::wstring wBuffer, wConverted;
g_charsetConverter.utf8ToW(ret, wBuffer, false);
HTML::CHTMLUtil::ConvertHTMLToW(wBuffer, wConverted);
g_charsetConverter.wToUTF8(wConverted, ret);
return ret;
}
bool CShoutcastFile::Open(const CURL& url)
{
CURL url... | `XFILE` not needed but no harm in keeping | g_charsetConverter.ToUtf8(m_fileCharset, str, ret);
std::wstring wBuffer, wConverted;
g_charsetConverter.utf8ToW(ret, wBuffer, false);
HTML::CHTMLUtil::ConvertHTMLToW(wBuffer, wConverted);
g_charsetConverter.wToUTF8(wConverted, ret);
return ret;
}
bool CShoutcastFile::Open(const CURL& url)
{
CURL url... | @@ -95,7 +95,7 @@ bool CShoutcastFile::Open(const CURL& url)
bool result = m_file.Open(url2);
if (result)
{
- m_fileCharset = m_file.GetProperty(XFILE::FILE_PROPERTY_CONTENT_CHARSET);
+ m_fileCharset = m_file.GetProperty(XFILE::FileProperty::CONTENT_CHARSET); | xbmc/filesystem/ShoutcastFile.cpp | 26 | C++ | 0.286 | suggestion | 41 | 51 | 51 | false | XFILE::FileProperty: convert to enum class | 26,217 | xbmc/xbmc | 17,740 | C++ | garbear | notspiff |
else
{
return audioManager.isWiredHeadsetOn() || audioManager.isBluetoothA2dpOn();
}
}
} // namespace
void CXBMCApp::onResume()
{
android_printf("%s: ", __PRETTY_FUNCTION__);
if (g_application.IsInitialized() &&
CServiceBroker::GetWinSystem()->GetOSScreenSaver()->IsInhibited())
KeepScreenOn(tr... | This check makes only sense, when refcounting would be involved. Therefore assign the GetAppMessenger to a ~local~ temporary variable and then use this for sending the message?
e.g. mymessenger = CServiceBroker::GetAppMessenger();
if (mymessenger)
{
}
Right? | else
{
return audioManager.isWiredHeadsetOn() || audioManager.isBluetoothA2dpOn();
}
}
} // namespace
void CXBMCApp::onResume()
{
android_printf("%s: ", __PRETTY_FUNCTION__);
if (g_application.IsInitialized() &&
CServiceBroker::GetWinSystem()->GetOSScreenSaver()->IsInhibited())
KeepScreenOn(tr... | @@ -318,6 +318,9 @@ void CXBMCApp::onResume()
appPower->ResetShutdownTimers();
}
+ if (CServiceBroker::GetAppMessenger()) | xbmc/platform/android/activity/XBMCApp.cpp | 26 | C++ | 0.571 | question | 267 | 51 | 51 | false | [Android] Mark window dirty on app resume | 26,218 | xbmc/xbmc | 17,740 | C++ | fritsch | joseluismarti |
int SetDetailsForItem(CVideoInfoTag& details, const std::map<std::string, std::string> &artwork);
int SetDetailsForItem(int id, const MediaType& mediaType, CVideoInfoTag& details, const std::map<std::string, std::string> &artwork);
int SetDetailsForMovie(CVideoInfoTag& details,
const std... | Please drop `const` from the ints here. As ints are passed by value, a copy is always created, so const never affects anything outside this function, and as a result adds clutter to the external API without providing any real protection or optimization. | int SetDetailsForItem(CVideoInfoTag& details, const std::map<std::string, std::string> &artwork);
int SetDetailsForItem(int id, const MediaType& mediaType, CVideoInfoTag& details, const std::map<std::string, std::string> &artwork);
int SetDetailsForMovie(CVideoInfoTag& details,
const std... | @@ -592,19 +592,20 @@ class CVideoDatabase : public CDatabase
const std::map<std::string, std::string>& artwork,
int idShow,
int idEpisode = -1);
- bool SetFileForEpisode(const std::string& fileAndPath, int idEpisode, int idFile);
- b... | xbmc/video/VideoDatabase.h | 26 | C/C++ | 0.571 | suggestion | 253 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | garbear | 78andyp |
\param artwork the artwork map for the show.
\param seasonArt the artwork map for seasons.
\param idTvShow the database id of the tvshow if known (defaults to -1)
\return the id of the tvshow.
*/
int SetDetailsForTvShow(const std::vector< std::pair<std::string, std::string> > &paths, CVideoInfoTag& det... | A setter with a const modifier is a red flag. Setters clearly mutate state, so shouldn't be const. And as long as I noticed this, const should be dropped from the DB getters too. The getters call into mysql, and even though it's a DB read, it still mutates internal state of the sql object. | \param artwork the artwork map for the show.
\param seasonArt the artwork map for seasons.
\param idTvShow the database id of the tvshow if known (defaults to -1)
\return the id of the tvshow.
*/
int SetDetailsForTvShow(const std::vector< std::pair<std::string, std::string> > &paths, CVideoInfoTag& det... | @@ -592,19 +592,20 @@ class CVideoDatabase : public CDatabase
const std::map<std::string, std::string>& artwork,
int idShow,
int idEpisode = -1);
- bool SetFileForEpisode(const std::string& fileAndPath, int idEpisode, int idFile);
- b... | xbmc/video/VideoDatabase.h | 26 | C/C++ | 0.571 | suggestion | 290 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | garbear | 78andyp |
data["type"] = item.GetVideoInfoTag()->m_type;
CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::VideoLibrary,
"OnUpdate", data);
}
updateListing = true;
}
}
if... | I've spent some time reviewing the first commit. And this check confuses me. It looks like the change in this file causes the SetFile() calls below to be omitted if *not* bluray. And the commit title is `Fix videoversions and bluray:// paths.`, so it's not clear why behavior is modified for non-bluray files. | data["type"] = item.GetVideoInfoTag()->m_type;
CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::VideoLibrary,
"OnUpdate", data);
}
updateListing = true;
}
}
//... | @@ -183,24 +182,29 @@ void CSaveFileState::DoWork(CFileItem& item,
if (!videodatabase.GetStreamDetails(dbItem) ||
dbItem.GetVideoInfoTag()->m_streamDetails != item.GetVideoInfoTag()->m_streamDetails)
{
- const int idFile = videodatabase.SetStreamDetailsForFile(
+ ... | xbmc/utils/SaveFileStateJob.cpp | 26 | C++ | 0.857 | suggestion | 309 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | garbear | 78andyp |
data["type"] = item.GetVideoInfoTag()->m_type;
CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::VideoLibrary,
"OnUpdate", data);
}
updateListing = true;
}
}
if... | This value is overwritten below for bluray paths. If `videoDbSuccess` is set to false, the calls below should be skipped, right?. When a success flag is assigned multiple times, I would expect the operation to be a logical `&=` effectively. | data["type"] = item.GetVideoInfoTag()->m_type;
CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::VideoLibrary,
"OnUpdate", data);
}
updateListing = true;
}
}
//... | @@ -183,24 +182,29 @@ void CSaveFileState::DoWork(CFileItem& item,
if (!videodatabase.GetStreamDetails(dbItem) ||
dbItem.GetVideoInfoTag()->m_streamDetails != item.GetVideoInfoTag()->m_streamDetails)
{
- const int idFile = videodatabase.SetStreamDetailsForFile(
+ ... | xbmc/utils/SaveFileStateJob.cpp | 26 | C++ | 0.786 | suggestion | 240 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | garbear | 78andyp |
{
std::string name2(strMovieName);
URIUtils::GetParentPath(name2,strMovieName);
if (URIUtils::IsInArchive(m_strPath))
{
// Try to get archive itself, if empty take path before
name2 = CURL(m_strPath).GetHostName();
if (name2.empty())
name2 = strMovieName;
URIUtils::Get... | `this->GetDynPath()` -> `GetDynPath()` | {
std::string name2(strMovieName);
URIUtils::GetParentPath(name2,strMovieName);
if (URIUtils::IsInArchive(m_strPath))
{
// Try to get archive itself, if empty take path before
name2 = CURL(m_strPath).GetHostName();
if (name2.empty())
name2 = strMovieName;
URIUtils::Get... | @@ -2028,19 +2011,11 @@ std::string CFileItem::GetLocalMetadataPath() const
if (m_bIsFolder && !IsFileFolder())
return m_strPath;
- std::string parent{};
- if (VIDEO::IsBlurayPlaylist(*this))
- parent = URIUtils::GetParentPath(GetBlurayPath());
- else
- parent = URIUtils::GetParentPath(m_strPath);
- ... | xbmc/FileItem.cpp | 26 | C++ | 0.286 | suggestion | 38 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | ksooo | 78andyp |
URIUtils::GetParentPath(name2,strMovieName);
if (URIUtils::IsInArchive(m_strPath))
{
// Try to get archive itself, if empty take path before
name2 = CURL(m_strPath).GetHostName();
if (name2.empty())
name2 = strMovieName;
URIUtils::GetParentPath(name2, strMovieName);
}
... | `this->GetDynPath()` -> `GetDynPath()` | URIUtils::GetParentPath(name2,strMovieName);
if (URIUtils::IsInArchive(m_strPath))
{
// Try to get archive itself, if empty take path before
name2 = CURL(m_strPath).GetHostName();
if (name2.empty())
name2 = strMovieName;
URIUtils::GetParentPath(name2, strMovieName);
}
... | @@ -2028,19 +2011,11 @@ std::string CFileItem::GetLocalMetadataPath() const
if (m_bIsFolder && !IsFileFolder())
return m_strPath;
- std::string parent{};
- if (VIDEO::IsBlurayPlaylist(*this))
- parent = URIUtils::GetParentPath(GetBlurayPath());
- else
- parent = URIUtils::GetParentPath(m_strPath);
- ... | xbmc/FileItem.cpp | 26 | C++ | 0.286 | suggestion | 38 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | ksooo | 78andyp |
updateListing = true;
}
}
if (item.HasVideoInfoTag() && item.GetVideoInfoTag()->HasStreamDetails() &&
!item.IsLiveTV())
{
CFileItem dbItem(item);
// Check whether the item's db streamdetails need updating
if (!videodatabase.GetSt... | `item.GetVideoInfoTag()` returns a pointer, not a reference. Please change to `const CVideoInfoTag*` to be explicit. `auto` imo here is just for the lazy, but decreases code readability. |
updateListing = true;
}
}
//! @todo videoDBSuccess will always be true as not updated yet for play count and bookmark changes
if (videoDbSuccess)
videodatabase.CommitTransaction();
else
videodatabase.RollbackTransaction();
videodatabase... | @@ -183,24 +182,29 @@ void CSaveFileState::DoWork(CFileItem& item,
if (!videodatabase.GetStreamDetails(dbItem) ||
dbItem.GetVideoInfoTag()->m_streamDetails != item.GetVideoInfoTag()->m_streamDetails)
{
- const int idFile = videodatabase.SetStreamDetailsForFile(
+ ... | xbmc/utils/SaveFileStateJob.cpp | 26 | C++ | 0.714 | suggestion | 186 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | ksooo | 78andyp |
{
CFileItem dbItem(item);
// Check whether the item's db streamdetails need updating
if (!videodatabase.GetStreamDetails(dbItem) ||
dbItem.GetVideoInfoTag()->m_streamDetails != item.GetVideoInfoTag()->m_streamDetails)
{
videoDbSuccess = videodat... | `item.GetVideoInfoTag()` returns a pointer, not a reference. Please change to `const CVideoInfoTag*` to be explicit. `auto` imo here is just for the lazy, but decreases code readability. | videodatabase.CommitTransaction();
else
videodatabase.RollbackTransaction();
videodatabase.BeginTransaction();
if (item.HasVideoInfoTag() && item.GetVideoInfoTag()->HasStreamDetails() &&
!item.IsLiveTV())
{
CFileItem dbItem(item);
// ... | @@ -183,24 +182,29 @@ void CSaveFileState::DoWork(CFileItem& item,
if (!videodatabase.GetStreamDetails(dbItem) ||
dbItem.GetVideoInfoTag()->m_streamDetails != item.GetVideoInfoTag()->m_streamDetails)
{
- const int idFile = videodatabase.SetStreamDetailsForFile(
+ ... | xbmc/utils/SaveFileStateJob.cpp | 26 | C++ | 0.714 | suggestion | 186 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | ksooo | 78andyp |
if (item.HasVideoInfoTag() && item.GetVideoInfoTag()->HasStreamDetails() &&
!item.IsLiveTV())
{
CFileItem dbItem(item);
// Check whether the item's db streamdetails need updating
if (!videodatabase.GetStreamDetails(dbItem) ||
dbItem.GetVideoInfoT... | As far as I can see you need `currentFileId` only inside the if-clause. Please move the calculation of `currentFileId` inside the if block. |
//! @todo videoDBSuccess will always be true as not updated yet for play count and bookmark changes
if (videoDbSuccess)
videodatabase.CommitTransaction();
else
videodatabase.RollbackTransaction();
videodatabase.BeginTransaction();
if (item.HasVideoInfoTag() ... | @@ -183,24 +182,29 @@ void CSaveFileState::DoWork(CFileItem& item,
if (!videodatabase.GetStreamDetails(dbItem) ||
dbItem.GetVideoInfoTag()->m_streamDetails != item.GetVideoInfoTag()->m_streamDetails)
{
- const int idFile = videodatabase.SetStreamDetailsForFile(
+ ... | xbmc/utils/SaveFileStateJob.cpp | 26 | C++ | 0.714 | suggestion | 139 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | ksooo | 78andyp |
{
videoDbSuccess = videodatabase.SetStreamDetailsForFile(
item.GetVideoInfoTag()->m_streamDetails, progressTrackingFile);
updateListing = !videoDbSuccess;
}
}
// See if fileId needs updating
if (URIUtils::IsBlurayPath(item.GetDynPath()... | As far as I can see you need `currentFileId` only inside the if-clause. Please move the calculation of `currentFileId` inside the if block. | !item.IsLiveTV())
{
CFileItem dbItem(item);
// Check whether the item's db streamdetails need updating
if (!videodatabase.GetStreamDetails(dbItem) ||
dbItem.GetVideoInfoTag()->m_streamDetails != item.GetVideoInfoTag()->m_streamDetails)
{
... | @@ -183,24 +182,29 @@ void CSaveFileState::DoWork(CFileItem& item,
if (!videodatabase.GetStreamDetails(dbItem) ||
dbItem.GetVideoInfoTag()->m_streamDetails != item.GetVideoInfoTag()->m_streamDetails)
{
- const int idFile = videodatabase.SetStreamDetailsForFile(
+ ... | xbmc/utils/SaveFileStateJob.cpp | 26 | C++ | 0.714 | suggestion | 139 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | ksooo | 78andyp |
std::string URIUtils::GetBasePath(const std::string& strPath)
{
std::string strCheck(strPath);
if (IsStack(strPath))
strCheck = CStackDirectory::GetFirstStackedFile(strPath);
std::string strDirectory = GetDirectory(strCheck);
if (IsInRAR(strCheck))
{
std::string strPath=strDirectory;
GetParentPat... | I would go with a `const std::string& file`, not a copy (by-val vs. by-ref param). The implementation detail that you need to modify the parameter's value should not be exposed to the interface of the function. | std::string URIUtils::GetBasePath(const std::string& strPath)
{
std::string strCheck(strPath);
if (IsStack(strPath))
strCheck = CStackDirectory::GetFirstStackedFile(strPath);
std::string strDirectory = GetDirectory(strCheck);
if (IsInRAR(strCheck))
{
std::string strPath=strDirectory;
GetParentPat... | @@ -455,6 +455,45 @@ std::string URIUtils::GetBasePath(const std::string& strPath)
return strDirectory;
}
+std::string URIUtils::GetDiscBase(std::string file)
+{
+ if (IsBlurayPath(file))
+ file = GetBlurayFile(file); | xbmc/utils/URIUtils.cpp | 26 | C++ | 0.786 | suggestion | 210 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | ksooo | 78andyp |
std::string strCheck(strPath);
if (IsStack(strPath))
strCheck = CStackDirectory::GetFirstStackedFile(strPath);
std::string strDirectory = GetDirectory(strCheck);
if (IsInRAR(strCheck))
{
std::string strPath=strDirectory;
GetParentPath(strPath, strDirectory);
}
if (IsStack(strPath))
{
st... | If I see this right, this variable can be `const std::string`. | std::string strCheck(strPath);
if (IsStack(strPath))
strCheck = CStackDirectory::GetFirstStackedFile(strPath);
std::string strDirectory = GetDirectory(strCheck);
if (IsInRAR(strCheck))
{
std::string strPath=strDirectory;
GetParentPath(strPath, strDirectory);
}
if (IsStack(strPath))
{
st... | @@ -455,6 +455,45 @@ std::string URIUtils::GetBasePath(const std::string& strPath)
return strDirectory;
}
+std::string URIUtils::GetDiscBase(std::string file)
+{
+ if (IsBlurayPath(file))
+ file = GetBlurayFile(file);
+
+ std::string parent{GetParentPath(file)}; | xbmc/utils/URIUtils.cpp | 26 | C++ | 0.357 | suggestion | 62 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | ksooo | 78andyp |
return GetParentPath(parent); // go back up another one
return parent;
}
std::string URIUtils::GetDiscBasePath(const std::string& file)
{
std::string base{GetDiscBase(file)};
if (IsDiscImage(base))
return GetDirectory(base);
return base;
}
std::string URIUtils::GetBlurayFile(const std::string& path)
{... | I think this method should return an empty string if item has no bluray path. The name of the method implies this, if I understand the code correctly. | parentFolder = GetFileName(parentFolder);
if (StringUtils::EqualsNoCase(parentFolder, "VIDEO_TS") ||
StringUtils::EqualsNoCase(parentFolder, "BDMV"))
return GetParentPath(parent); // go back up another one
return parent;
}
std::string URIUtils::GetDiscBasePath(const std::string& file)
{
std::string b... | @@ -455,6 +455,45 @@ std::string URIUtils::GetBasePath(const std::string& strPath)
return strDirectory;
}
+std::string URIUtils::GetDiscBase(std::string file)
+{
+ if (IsBlurayPath(file))
+ file = GetBlurayFile(file);
+
+ std::string parent{GetParentPath(file)};
+ std::string parentFolder{parent};
+ Remove... | xbmc/utils/URIUtils.cpp | 26 | C++ | 0.5 | suggestion | 150 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | ksooo | 78andyp |
{
EXPECT_TRUE(URIUtils::IsUPnP("upnp://path/to/file"));
}
TEST_F(TestURIUtils, IsURL)
{
EXPECT_TRUE(URIUtils::IsURL("someprotocol://path/to/file"));
EXPECT_FALSE(URIUtils::IsURL("/path/to/file"));
}
TEST_F(TestURIUtils, IsVideoDb)
{
EXPECT_TRUE(URIUtils::IsVideoDb("videodb://path/to/file"));
}
TEST_F(TestURI... | I would ad a negative test here as well. Just hand in something not starting with bluray:// | {
EXPECT_TRUE(URIUtils::IsUPnP("upnp://path/to/file"));
}
TEST_F(TestURIUtils, IsURL)
{
EXPECT_TRUE(URIUtils::IsURL("someprotocol://path/to/file"));
EXPECT_FALSE(URIUtils::IsURL("/path/to/file"));
}
TEST_F(TestURIUtils, IsVideoDb)
{
EXPECT_TRUE(URIUtils::IsVideoDb("videodb://path/to/file"));
}
TEST_F(TestURI... | @@ -442,9 +442,9 @@ TEST_F(TestURIUtils, IsZIP)
EXPECT_FALSE(URIUtils::IsZIP("zip://path/to/file"));
}
-TEST_F(TestURIUtils, IsBluray)
+TEST_F(TestURIUtils, IsBlurayPath)
{
- EXPECT_TRUE(URIUtils::IsBluray("bluray://path/to/file"));
+ EXPECT_TRUE(URIUtils::IsBlurayPath("bluray://path/to/file")); | xbmc/utils/test/TestURIUtils.cpp | 26 | C++ | 0.143 | suggestion | 91 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | ksooo | 78andyp |
if (GetEpisodeInfo(strFilenameAndPath, details))
return true;
if (GetMusicVideoInfo(strFilenameAndPath, details))
return true;
if (GetFileInfo(strFilenameAndPath, details))
return true;
return false;
}
bool CVideoDatabase::HasMovieInfo(const std::string& strFilenameAndPath)
{
try
{
if (nul... | There is already a method `CVideoDatabase::GetMovieId(const std::string& strFilenameAndPath)`. Why can't you just use it?
In this case you would not even need the new metod `CVideoDatabase::GetMovieId(int fileId)` you have introduced with this PR. | }
return false;
}
bool CVideoDatabase::HasTvShowInfo(const std::string& strPath)
{
try
{
if (nullptr == m_pDB)
return false;
if (nullptr == m_pDS)
return false;
int idTvShow = GetTvShowId(strPath);
return (idTvShow > 0); // index of zero is also invalid
}
catch (...)
{
CLo... | @@ -1992,8 +2017,15 @@ bool CVideoDatabase::HasMovieInfo(const std::string& strFilenameAndPath)
return false;
if (nullptr == m_pDS)
return false;
+
int idMovie = GetMovieId(strFilenameAndPath);
- return (idMovie > 0); // index of zero is also invalid
+ if (idMovie > 0) // index of zero is ... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.786 | suggestion | 250 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | ksooo | 78andyp |
std::string strPaths;
for (const auto& i : paths)
strPaths += StringUtils::Format(",{}", i);
sql += PrepareSQL(" AND path.idPath IN (%s)", strPaths.substr(1).c_str());
}
// For directory caching to work properly, we need to sort the files by path
sql += " ORDER BY path.strPath";
... | Is this just here because of the inconsitency in using path vs. dynpath with bluray urls? Reads like a hack or workaround. | *CMediaSourceSettings::GetInstance().GetSources("video"));
CServiceBroker::GetMediaManager().GetRemovableDrives(videoSources);
int total = m_pDS2->num_rows();
int current = 0;
std::string lastDir;
bool gotDir = true;
while (!m_pDS2->eof())
{
std::string path... | @@ -10171,6 +10290,10 @@ void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle,
if (URIUtils::IsInArchive(fullPath))
fullPath = CURL(fullPath).GetHostName();
+ // if bluray:// get actual path
+ if (URIUtils::IsBlurayPath(fullPath))
+ fullPath = URIUtils::Get... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.5 | question | 122 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | ksooo | 78andyp |
}
int CVideoDatabase::GetFileIdByEpisode(int idEpisode)
{
if (!m_pDB || !m_pDS)
return -1;
int idFile = -1;
try
{
m_pDS->query(PrepareSQL("SELECT idFile FROM episode WHERE idEpisode = %i", idEpisode));
if (!m_pDS->eof())
{
idFile = m_pDS->fv("idFile").get_asInt();
}
m_pDS->clo... | I think this can be implemented far more simple using `GetSingleValueInt`method.
```c++
const std::string query{PrepareSQL("SELECT idFile FROM episode WHERE idEpisode = %i", idEpisode)};
const int idFile{GetSingleValueInt(query, m_pDS)};
return idFile > 0 ? idFile : -1;
``` | return idFile;
}
void CVideoDatabase::GetSameVideoItems(const CFileItem& item, CFileItemList& items)
{
if (!m_pDB || !m_pDS)
return;
std::vector<int> itemIds;
int dbId = item.GetVideoInfoTag()->m_iDbId;
MediaType mediaType = item.GetVideoInfoTag()->m_type;
try
{
// get items with same unique i... | @@ -4052,6 +4115,32 @@ int CVideoDatabase::GetFileIdByMovie(int idMovie)
return idFile;
}
+int CVideoDatabase::GetFileIdByEpisode(int idEpisode)
+{
+ if (!m_pDB || !m_pDS)
+ return -1;
+
+ int idFile = -1;
+
+ try
+ {
+ m_pDS->query(PrepareSQL("SELECT idFile FROM episode WHERE idEpisode = %i", idEpisode... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.857 | suggestion | 287 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | ksooo | 78andyp |
if (idFile < 0)
return false;
try
{
assert(m_pDB->in_transaction());
std::string sql = PrepareSQL("UPDATE movie SET idFile=%i WHERE idFile=%i", idFile, oldIdFile);
m_pDS->exec(sql);
sql = PrepareSQL("UPDATE videoversion SET idFile=%i WHERE idFile=%i AND media_type='movie'",
... | Another opportunity to use `GetSingleValueInt()`?
if (GetSingle ... == 0) | return false;
try
{
std::string sql = PrepareSQL("UPDATE movie SET idFile=%i WHERE idFile=%i AND idMovie=%i",
idFile, oldIdFile, idMovie);
m_pDS->exec(sql);
sql = PrepareSQL(
"UPDATE videoversion SET idFile=%i WHERE idFile=%i AND media_type='movie' AND idMe... | @@ -3034,28 +3042,88 @@ bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpi
return false;
}
-bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int idFile)
+bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int oldIdFile)
{
+ const i... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.571 | suggestion | 76 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | ksooo | 78andyp |
int path{-1};
std::string strPath;
if (!m_pDS->eof())
{
path = m_pDS->fv("idPath").get_asInt();
strPath = m_pDS->fv("strPath").get_asString();
}
// Remove file and any associated bookmarks and streamdetails
sql = PrepareSQL("DELETE FROM files WHERE idFile = %i", idFile);
m_p... |
Another opportunity to use `GetSingleValueInt()`?
if (GetSingle ... == 0)
| idFile);
m_pDS->query(sql);
int idPath{-1};
std::string strPath;
if (!m_pDS->eof())
{
idPath = m_pDS->fv("idPath").get_asInt();
strPath = m_pDS->fv("strPath").get_asString();
}
// Associated bookmarks and streamdetails deleted by delete t... | @@ -3034,28 +3042,88 @@ bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpi
return false;
}
-bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int idFile)
+bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int oldIdFile)
{
+ const i... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.571 | suggestion | 82 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | ksooo | 78andyp |
PrepareSQL("UPDATE episode SET idFile=%i WHERE idEpisode=%i", idFile, idEpisode);
m_pDS->exec(sql);
DeleteFile(oldIdFile);
return true;
}
catch (...)
{
CLog::Log(LOGERROR, "{} ({}) failed", __FUNCTION__, idEpisode);
}
return false;
}
bool CVideoDatabase::SetFileForMovie(const std::st... | Please add the idMovie in the where for safety. | return DeleteFile(oldIdFile);
}
catch (...)
{
CLog::LogF(LOGERROR, " idFile {}, fileAndPath {}, idEpisode {}, oldIdFile {} - failed", idFile,
fileAndPath, idEpisode, oldIdFile);
}
return false;
}
bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int oldI... | @@ -3034,28 +3042,88 @@ bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpi
return false;
}
-bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int idFile)
+bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int oldIdFile)
{
+ const i... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.071 | suggestion | 47 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
{
assert(m_pDB->in_transaction());
std::string sql =
PrepareSQL("UPDATE episode SET idFile=%i WHERE idEpisode=%i", idFile, idEpisode);
m_pDS->exec(sql);
DeleteFile(oldIdFile);
return true;
}
catch (...)
{
CLog::Log(LOGERROR, "{} ({}) failed", __FUNCTION__, idEpisode);
}
retu... | Please add the idMovie in the where for safety. It's the primary key of the table. | try
{
m_pDS->exec(PrepareSQL("UPDATE episode SET idFile=%i WHERE idEpisode=%i", idFile, idEpisode));
return DeleteFile(oldIdFile);
}
catch (...)
{
CLog::LogF(LOGERROR, " idFile {}, fileAndPath {}, idEpisode {}, oldIdFile {} - failed", idFile,
fileAndPath, idEpisode, oldIdFile);
}
... | @@ -3034,28 +3042,88 @@ bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpi
return false;
}
-bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int idFile)
+bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int oldIdFile)
{
+ const i... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.143 | suggestion | 82 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
{
const int idFile = AddFile(fileAndPath);
if (idFile < 0)
return false;
try
{
assert(m_pDB->in_transaction());
std::string sql = PrepareSQL("UPDATE movie SET idFile=%i WHERE idFile=%i", idFile, oldIdFile);
m_pDS->exec(sql);
sql = PrepareSQL("UPDATE videoversion SET idFile=%i WHERE idFile=... | There may be some user bookmarks to transfer to the new file (not resume point or episode bookmarks). Though it's debatable as useful only when switching between playlists, and will a disc always have a single movie. | const int idFile{AddFile(fileAndPath)};
if (idFile < 0)
return false;
try
{
std::string sql = PrepareSQL("UPDATE movie SET idFile=%i WHERE idFile=%i AND idMovie=%i",
idFile, oldIdFile, idMovie);
m_pDS->exec(sql);
sql = PrepareSQL(
"UPDATE videoversion S... | @@ -3034,28 +3042,88 @@ bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpi
return false;
}
-bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int idFile)
+bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int oldIdFile)
{
+ const i... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.571 | suggestion | 216 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
idFile, oldIdFile);
m_pDS->exec(sql);
if (GetSingleValueInt(PrepareSQL("SELECT idFile FROM streamdetails WHERE idFile = %i", idFile),
m_pDS) == 0)
{
sql = PrepareSQL("UPDATE streamdetails SET idFile=%i WHERE idFile=%i", idFile, oldIdFile);
m_pDS->e... | please bring videoversion in there as well. | idFile, oldIdFile);
m_pDS->exec(sql);
sql = PrepareSQL("UPDATE streamdetails SET idFile=%i WHERE idFile=%i AND NOT EXISTS (SELECT 1 "
"FROM streamdetails WHERE idFile=%i)",
idFile, oldIdFile, idFile);
m_pDS->exec(sql);
return DeleteFile(ol... | @@ -3034,28 +3042,88 @@ bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpi
return false;
}
-bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int idFile)
+bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int oldIdFile)
{
+ const i... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.071 | suggestion | 43 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
// First check not multiple references to file (eg. episodes)
std::string sql{PrepareSQL("SELECT idFile FROM movie WHERE idFile = %i UNION SELECT idFile FROM "
"episode WHERE idFile = %i",
idFile, idFile)};
m_pDS->query(sql);
if (m_pDS->eof())
{
//... | Aren't bookmarks and stream details already covered by the delete trigger of files? | // First check no other references to file (eg. other episodes)
std::string sql{PrepareSQL("SELECT idFile FROM movie WHERE idFile = %i "
"UNION SELECT idFile FROM episode WHERE idFile = %i "
"UNION SELECT idFile FROM videoversion WHERE idFile = %i",
... | @@ -3034,28 +3042,88 @@ bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpi
return false;
}
-bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int idFile)
+bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int oldIdFile)
{
+ const i... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.143 | question | 83 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
DeleteFile(oldIdFile);
return true;
}
catch (...)
{
CLog::Log(LOGERROR, "{} ({}) failed", __FUNCTION__, idFile);
}
return false;
}
void CVideoDatabase::DeleteFile(int idFile)
{
// First check not multiple references to file (eg. episodes)
std::string sql{PrepareSQL("SELECT idFile FROM movie ... | please call the variable idPath | }
catch (...)
{
CLog::LogF(LOGERROR, " idFile {}, fileAndPath {}, idMovie {}, oldIdFile {} - failed", idFile,
fileAndPath, idMovie, oldIdFile);
}
return false;
}
bool CVideoDatabase::DeleteFile(int idFile)
{
try
{
// First check no other references to file (eg. other episodes)
... | @@ -3034,28 +3042,88 @@ bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpi
return false;
}
-bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int idFile)
+bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int oldIdFile)
{
+ const i... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.071 | suggestion | 31 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
"files.idPath WHERE idFile = %i",
idFile);
m_pDS->query(sql);
int path{-1};
std::string strPath;
if (!m_pDS->eof())
{
path = m_pDS->fv("idPath").get_asInt();
strPath = m_pDS->fv("strPath").get_asString();
}
// Remove file and any associa... | not runtime tested, but this may return multiple rows, especially for episodes. Is that on purpose? not sure GetSingleValueInt is meant for that,
Is there a reason to include the path table in the query? | sql = PrepareSQL("SELECT path.idPath, path.strPath FROM path "
"JOIN files ON path.idPath = files.idPath "
"WHERE idFile = %i",
idFile);
m_pDS->query(sql);
int idPath{-1};
std::string strPath;
if (!m_pDS->eof())
{
... | @@ -3034,28 +3042,88 @@ bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpi
return false;
}
-bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int idFile)
+bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int oldIdFile)
{
+ const i... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.357 | question | 204 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
if (item.HasVideoInfoTag() && item.GetVideoInfoTag()->HasStreamDetails() &&
!item.IsLiveTV())
{
CFileItem dbItem(item);
// Check whether the item's db streamdetails need updating
if (!videodatabase.GetStreamDetails(dbItem) ||
dbItem.GetVideoInfoT... | I don't think that's going to work for versions that are not the default version of a movie. If tag->m_iFileId points to the originally played file, then it could be used and eliminate the need for GetFileIdByMovie at the same time.
For safety, passing the iDbId and the current file id to SetFileForMovie would be good... |
//! @todo videoDBSuccess will always be true as not updated yet for play count and bookmark changes
if (videoDbSuccess)
videodatabase.CommitTransaction();
else
videodatabase.RollbackTransaction();
videodatabase.BeginTransaction();
if (item.HasVideoInfoTag() ... | @@ -183,23 +182,32 @@ void CSaveFileState::DoWork(CFileItem& item,
if (!videodatabase.GetStreamDetails(dbItem) ||
dbItem.GetVideoInfoTag()->m_streamDetails != item.GetVideoInfoTag()->m_streamDetails)
{
- const int idFile = videodatabase.SetStreamDetailsForFile(
+ ... | xbmc/utils/SaveFileStateJob.cpp | 26 | C++ | 0.643 | suggestion | 321 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
// Check whether the item's db streamdetails need updating
if (!videodatabase.GetStreamDetails(dbItem) ||
dbItem.GetVideoInfoTag()->m_streamDetails != item.GetVideoInfoTag()->m_streamDetails)
{
videoDbSuccess = videodatabase.SetStreamDetailsForFile(
... | I took a look and looks like we can rely on tag->m_iFileId for the originally played file. It's key to pass that value to SetFileForMovie because there is no guarantee that what was played was the default version of a movie, and that we can get to the idFile from the idMovie.
The current GUI makes this case difficult ... |
// Check whether the item's db streamdetails need updating
if (!videodatabase.GetStreamDetails(dbItem) ||
dbItem.GetVideoInfoTag()->m_streamDetails != item.GetVideoInfoTag()->m_streamDetails)
{
videoDbSuccess = videodatabase.SetStreamDetailsForFile(
... | @@ -183,24 +189,33 @@ void CSaveFileState::DoWork(CFileItem& item,
if (!videodatabase.GetStreamDetails(dbItem) ||
dbItem.GetVideoInfoTag()->m_streamDetails != item.GetVideoInfoTag()->m_streamDetails)
{
- const int idFile = videodatabase.SetStreamDetailsForFile(
+ ... | xbmc/utils/SaveFileStateJob.cpp | 26 | C++ | 0.643 | suggestion | 885 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
{
assert(m_pDB->in_transaction());
std::string sql =
PrepareSQL("UPDATE episode SET idFile=%i WHERE idEpisode=%i", idFile, idEpisode);
m_pDS->exec(sql);
DeleteFile(oldIdFile);
return true;
}
catch (...)
{
CLog::Log(LOGERROR, "{} ({}) failed", __FUNCTION__, idEpisode);
}
retu... | As mentioned in other comment, the original file id needs to come from the caller, because GetFileIdByMovie can only retrieve the file of the default version of a movie. | }
catch (...)
{
CLog::LogF(LOGERROR, " idFile {}, fileAndPath {}, idEpisode {}, oldIdFile {} - failed", idFile,
fileAndPath, idEpisode, oldIdFile);
}
return false;
}
bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int oldIdFile)
{
assert(m_pDB->in_transa... | @@ -3034,28 +3046,89 @@ bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpi
return false;
}
-bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int idFile)
+bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie)
{
+ const int... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.5 | suggestion | 169 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
const int idFile{AddFile(fileAndPath)};
if (idFile < 0)
return false;
const int oldIdFile{GetFileIdByMovie(idMovie)};
if (oldIdFile < 0)
return false;
try
{
assert(m_pDB->in_transaction());
std::string sql = PrepareSQL("UPDATE movie SET idFile=%i WHERE idFile=%i AND idMovie=%i",
... | In this case there can't be a record with idFile == 0 in the table so nothing bad can happen but that's a dangerous way to test record existence.
"SELECT 1 FROM ..." would be guaranteed to work regardless of field types or values.
That said, GetSingleValueInt is not well suited to this use case imo and a classic DS... | {
std::string sql = PrepareSQL("UPDATE movie SET idFile=%i WHERE idFile=%i AND idMovie=%i",
idFile, oldIdFile, idMovie);
m_pDS->exec(sql);
sql = PrepareSQL(
"UPDATE videoversion SET idFile=%i WHERE idFile=%i AND media_type='movie' AND idMedia=%i",
idFile, ... | @@ -3034,28 +3046,89 @@ bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpi
return false;
}
-bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int idFile)
+bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie)
{
+ const int... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.929 | refactor | 684 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
try
{
m_pDS->query(PrepareSQL(
"SELECT strPath FROM path JOIN files ON path.idPath = files.idPath WHERE idFile = %i",
idFile));
if (!m_pDS->eof())
{
return m_pDS->fv("strPath").get_asString();
}
m_pDS->close();
}
catch (...)
{
CLog::Log(LOGERROR, "{} failed for ... | It's OK to rely more on helper functions but this cosmetic change is not related to the fix and doesn't belong to this commit (or PR). | "SELECT strPath FROM path JOIN files ON path.idPath = files.idPath WHERE idFile = %i",
idFile));
if (!m_pDS->eof())
{
return m_pDS->fv("strPath").get_asString();
}
m_pDS->close();
}
catch (...)
{
CLog::Log(LOGERROR, "{} failed for file {}", __FUNCTION__, idFile);
}
... | @@ -4028,30 +4096,19 @@ std::string CVideoDatabase::GetFileBasePathById(int idFile)
int CVideoDatabase::GetFileIdByMovie(int idMovie)
{
- if (!m_pDB || !m_pDS)
- return -1;
-
- int idFile = -1;
-
- try
- {
- m_pDS->query(PrepareSQL("SELECT idFile FROM movie WHERE idMovie = %i", idMovie));
-
- if (!m_pD... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.5 | refactor | 134 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
videodatabase.AddBookMarkToFile(progressTrackingFile, bookmark, CBookmark::RESUME);
if (item.HasVideoInfoTag())
item.GetVideoInfoTag()->SetResumePoint(bookmark);
// UPnP announce resume point changes to clients
// however not if playcount is modified as t... | I'd only include the CommitTransaction at this time, with a todo to properly handle errors, as you did. | videodatabase.AddBookMarkToFile(progressTrackingFile, bookmark, CBookmark::RESUME);
if (item.HasVideoInfoTag())
item.GetVideoInfoTag()->SetResumePoint(bookmark);
// UPnP announce resume point changes to clients
// however not if playcount is modified as t... | @@ -174,6 +173,13 @@ void CSaveFileState::DoWork(CFileItem& item,
}
}
+ //! @todo videoDBSuccess will always be true as not updated yet for play count and bookmark changes
+ if (videoDbSuccess)
+ videodatabase.CommitTransaction();
+ else
+ videodatabase.Rollb... | xbmc/utils/SaveFileStateJob.cpp | 26 | C++ | 0.571 | suggestion | 103 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
bool CVideoDatabase::LoadVideoInfo(const std::string& strFilenameAndPath, CVideoInfoTag& details, int getDetails /* = VideoDbDetailsAll */)
{
if (GetMovieInfo(strFilenameAndPath, details))
return true;
if (GetEpisodeInfo(strFilenameAndPath, details))
return true;
if (GetMusicVideoInfo(strFilenameAndPath, ... | can you please revert those changes.
as a general rule I'd say it's ok to touch up code in immediate proximity to something changed by the commit, but not unrelated areas of the code. It creates unnecessary noise for the review. | bool CVideoDatabase::LoadVideoInfo(const std::string& strFilenameAndPath, CVideoInfoTag& details, int getDetails /* = VideoDbDetailsAll */)
{
if (GetMovieInfo(strFilenameAndPath, details))
return true;
if (GetEpisodeInfo(strFilenameAndPath, details))
return true;
if (GetMusicVideoInfo(strFilenameAndPath, ... | @@ -1992,8 +1992,10 @@ bool CVideoDatabase::HasMovieInfo(const std::string& strFilenameAndPath)
return false;
if (nullptr == m_pDS)
return false;
+
int idMovie = GetMovieId(strFilenameAndPath);
- return (idMovie > 0); // index of zero is also invalid
+ if (idMovie > 0) // index of zero is ... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.571 | suggestion | 229 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
SetArtForItem(idSeason, MediaTypeSeason, artwork);
// and insert the new row
std::string sql = PrepareSQL("UPDATE seasons SET season=%i", details.m_iSeason);
if (!details.m_strSortTitle.empty())
sql += PrepareSQL(", name='%s'", details.m_strSortTitle.c_str());
if (details.m_iUserRating > 0 &... | The old file id is also available from the tag (same as a movie). Please pass it down here and the lookup and the new lookup function won't be needed. | SetArtForItem(idSeason, MediaTypeSeason, artwork);
// and insert the new row
std::string sql = PrepareSQL("UPDATE seasons SET season=%i", details.m_iSeason);
if (!details.m_strSortTitle.empty())
sql += PrepareSQL(", name='%s'", details.m_strSortTitle.c_str());
if (details.m_iUserRating > 0 &&... | @@ -3017,13 +3019,23 @@ int CVideoDatabase::SetDetailsForSeason(const CVideoInfoTag& details, const std:
return -1;
}
-bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpisode, int idFile)
+bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpisode) | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.286 | suggestion | 150 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
CommitTransaction();
return idSeason;
}
catch (...)
{
CLog::Log(LOGERROR, "{} ({}) failed", __FUNCTION__, idSeason);
}
RollbackTransaction();
return -1;
}
bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpisode)
{
const int idFile = AddFile(fileAndPath);
if (id... | A temporary is not needed here, but should be const if it stays. |
return idSeason;
}
catch (...)
{
CLog::Log(LOGERROR, "{} ({}) failed", __FUNCTION__, idSeason);
}
RollbackTransaction();
return -1;
}
bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpisode, int oldIdFile)
{
assert(m_pDB->in_transaction());
const int idFile = AddF... | @@ -3017,13 +3019,23 @@ int CVideoDatabase::SetDetailsForSeason(const CVideoInfoTag& details, const std:
return -1;
}
-bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpisode, int idFile)
+bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpisode)
{
+ cons... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.357 | suggestion | 64 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
m_pDS->exec(sql.c_str());
CommitTransaction();
return idSeason;
}
catch (...)
{
CLog::Log(LOGERROR, "{} ({}) failed", __FUNCTION__, idSeason);
}
RollbackTransaction();
return -1;
}
bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpisode)
{
const int idFile = ... | please move to the top of the function, same for the Movie function. | CommitTransaction();
return idSeason;
}
catch (...)
{
CLog::Log(LOGERROR, "{} ({}) failed", __FUNCTION__, idSeason);
}
RollbackTransaction();
return -1;
}
bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpisode, int oldIdFile)
{
assert(m_pDB->in_transaction());
... | @@ -3017,13 +3019,23 @@ int CVideoDatabase::SetDetailsForSeason(const CVideoInfoTag& details, const std:
return -1;
}
-bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpisode, int idFile)
+bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpisode)
{
+ cons... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.357 | suggestion | 68 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
sql = PrepareSQL("UPDATE art SET media_id=%i WHERE media_id=%i AND media_type='videoversion'",
idFile, oldIdFile);
m_pDS->exec(sql);
sql = PrepareSQL("SELECT 1 FROM streamdetails WHERE idFile = %i", idFile);
m_pDS->query(sql);
if (m_pDS->eof())
{
sql = PrepareSQL("UPD... | please reformat on multiple lines so it's easier to read, like
```
std::string sql{PrepareSQL("SELECT idFile FROM movie WHERE idFile = %i "
"UNION SELECT idFile FROM episode WHERE idFile = %i "
"UNION SELECT idFile FROM videoversion WHERE idFile = %i",
... | idFile, oldIdFile, idFile);
m_pDS->exec(sql);
return DeleteFile(oldIdFile);
}
catch (...)
{
CLog::LogF(LOGERROR, " idFile {}, fileAndPath {}, idMovie {}, oldIdFile {} - failed", idFile,
fileAndPath, idMovie, oldIdFile);
}
return false;
}
bool CVideoDatabase::D... | @@ -3034,28 +3046,87 @@ bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpi
return false;
}
-bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int idFile)
+bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int oldIdFile)
... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.929 | style | 377 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
sql = PrepareSQL("UPDATE streamdetails SET idFile=%i WHERE idFile=%i", idFile, oldIdFile);
m_pDS->exec(sql);
}
DeleteFile(oldIdFile);
return true;
}
catch (...)
{
CLog::Log(LOGERROR, "{} ({}) failed", __FUNCTION__, idFile);
}
return false;
}
void CVideoDatabase::DeleteFile(int id... | please reformat for easier reading. for example
```
sql = PrepareSQL("SELECT path.idPath, path.strPath "
"FROM path "
" JOIN files ON path.idPath = files.idPath "
"WHERE idFile = %i",
```
there are no code guidelines for the embedded sql so diff... | fileAndPath, idMovie, oldIdFile);
}
return false;
}
bool CVideoDatabase::DeleteFile(int idFile)
{
try
{
// First check no other references to file (eg. other episodes)
std::string sql{PrepareSQL("SELECT idFile FROM movie WHERE idFile = %i "
"UNION SELECT id... | @@ -3034,28 +3046,87 @@ bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpi
return false;
}
-bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int idFile)
+bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int oldIdFile)
... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 1 | style | 567 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
sql = PrepareSQL("UPDATE art SET media_id=%i WHERE media_id=%i AND media_type='videoversion'",
idFile, oldIdFile);
m_pDS->exec(sql);
sql = PrepareSQL("SELECT 1 FROM streamdetails WHERE idFile = %i", idFile);
m_pDS->query(sql);
if (m_pDS->eof())
{
sql = PrepareSQL("UP... | suggestion: // First check for references to the file
A single reference is enough to abort, right?
A bool return status for errors would be good and would let the caller react.
A remaining reference is not an error and could just be logged at LOGDEBUG level. | "FROM streamdetails WHERE idFile=%i)",
idFile, oldIdFile, idFile);
m_pDS->exec(sql);
return DeleteFile(oldIdFile);
}
catch (...)
{
CLog::LogF(LOGERROR, " idFile {}, fileAndPath {}, idMovie {}, oldIdFile {} - failed", idFile,
fileAndPath, idMovi... | @@ -3034,28 +3046,87 @@ bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpi
return false;
}
-bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int idFile)
+bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int oldIdFile)
... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.857 | bug | 264 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
"episode WHERE idFile = %i UNION SELECT idFile FROM "
"videoversion WHERE idFile = %i",
idFile, idFile, idFile)};
m_pDS->query(sql);
if (m_pDS->eof())
{
// Get idPath
sql = PrepareSQL("SELECT path.idPath, path.strPath F... | Suggestion: combine the queries.
```
DELETE FROM path
WHERE idPath = %i
AND NOT EXISTS (SELECT 1 FROM files WHERE files.idPath = %i)
``` | sql = PrepareSQL("SELECT path.idPath, path.strPath FROM path "
"JOIN files ON path.idPath = files.idPath "
"WHERE idFile = %i",
idFile);
m_pDS->query(sql);
int idPath{-1};
std::string strPath;
if (!m_pDS->eof())
{
... | @@ -3034,28 +3046,87 @@ bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpi
return false;
}
-bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int idFile)
+bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int oldIdFile)
... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 1 | suggestion | 141 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
idFile, oldIdFile, idMovie);
m_pDS->exec(sql);
sql = PrepareSQL("UPDATE art SET media_id=%i WHERE media_id=%i AND media_type='videoversion'",
idFile, oldIdFile);
m_pDS->exec(sql);
sql = PrepareSQL("SELECT 1 FROM streamdetails WHERE idFile = %i", idFile);
m_pDS->query(s... | I think removing orphaned file and path is a different fix and belongs to a different commit or at least deserves a clear mention in the commit message.
|
sql = PrepareSQL("UPDATE streamdetails SET idFile=%i WHERE idFile=%i AND NOT EXISTS (SELECT 1 "
"FROM streamdetails WHERE idFile=%i)",
idFile, oldIdFile, idFile);
m_pDS->exec(sql);
return DeleteFile(oldIdFile);
}
catch (...)
{
CLog::LogF(LOGERROR, " idFi... | @@ -3034,28 +3046,87 @@ bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpi
return false;
}
-bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int idFile)
+bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int oldIdFile)
... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.286 | suggestion | 154 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
if (idFile < 0)
return false;
try
{
assert(m_pDB->in_transaction());
std::string sql = PrepareSQL("UPDATE movie SET idFile=%i WHERE idFile=%i AND idMovie=%i",
idFile, oldIdFile, idMovie);
m_pDS->exec(sql);
sql = PrepareSQL(
"UPDATE videoversion SET id... | Please simplify and combine as one query, something like:
```
UPDATE streamdetails SET idFile= %idFile
WHERE idFile= %oldIdFile
AND NOT EXISTS(SELECT 1 FROM streamdetails WHERE idFile = %idFile)
```
| std::string sql = PrepareSQL("UPDATE movie SET idFile=%i WHERE idFile=%i AND idMovie=%i",
idFile, oldIdFile, idMovie);
m_pDS->exec(sql);
sql = PrepareSQL(
"UPDATE videoversion SET idFile=%i WHERE idFile=%i AND media_type='movie' AND idMedia=%i",
idFile, oldI... | @@ -3034,28 +3046,87 @@ bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpi
return false;
}
-bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int idFile)
+bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int oldIdFile)
... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 1 | refactor | 205 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
return GetParentPath(parent); // go back up another one
return parent;
}
std::string URIUtils::GetDiscBasePath(const std::string& file)
{
std::string base{GetDiscBase(file)};
if (IsDiscImage(base))
return GetDirectory(base);
return base;
}
std::string URIUtils::GetBlurayFile(const std::string& path)
{... | this belongs to the previous commit to address the comment there. | return GetParentPath(parent); // go back up another one
return parent;
}
std::string URIUtils::GetDiscBasePath(const std::string& file)
{
std::string base{GetDiscBase(file)};
if (IsDiscImage(base))
return GetDirectory(base);
return base;
}
std::string URIUtils::GetBlurayFile(const std::string& path)
{... | @@ -455,20 +455,46 @@ std::string URIUtils::GetBasePath(const std::string& strPath)
return strDirectory;
}
+std::string URIUtils::GetDiscBase(const std::string& file)
+{
+ std::string discFile;
+ if (IsBluray(file))
+ discFile = GetBlurayFile(file);
+ else
+ discFile = file;
+
+ std::string parent{GetPa... | xbmc/utils/URIUtils.cpp | 26 | C++ | 0.143 | suggestion | 65 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
if (StringUtils::EqualsNoCase(parentFolder, "VIDEO_TS") ||
StringUtils::EqualsNoCase(parentFolder, "BDMV"))
return GetParentPath(parent); // go back up another one
return parent;
}
std::string URIUtils::GetDiscBasePath(const std::string& file)
{
std::string base{GetDiscBase(file)};
if (IsDiscImage(ba... | I know this was existing code, but please use `URIUtils::AddFileToFolder()` to join paths, e.g. `URIUtils::AddFileToFolder(url2.Get(), "BDMV", "index.bdmv")` | if (StringUtils::EqualsNoCase(parentFolder, "VIDEO_TS") ||
StringUtils::EqualsNoCase(parentFolder, "BDMV"))
return GetParentPath(parent); // go back up another one
return parent;
}
std::string URIUtils::GetDiscBasePath(const std::string& file)
{
std::string base{GetDiscBase(file)};
if (IsDiscImage(ba... | @@ -455,6 +455,48 @@ std::string URIUtils::GetBasePath(const std::string& strPath)
return strDirectory;
}
+std::string URIUtils::GetDiscBase(const std::string& file)
+{
+ std::string discFile;
+ if (IsBlurayPath(file))
+ discFile = GetBlurayFile(file);
+ else
+ discFile = file;
+
+ std::string parent{Ge... | xbmc/utils/URIUtils.cpp | 26 | C++ | 0.714 | suggestion | 157 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | garbear | 78andyp |
if (IsStack(strPath))
{
strCheck = strDirectory;
RemoveSlashAtEnd(strCheck);
if (GetFileName(strCheck).size() == 3 && StringUtils::StartsWithNoCase(GetFileName(strCheck), "cd"))
strDirectory = GetDirectory(strCheck);
}
return strDirectory;
}
std::string URIUtils::GetDiscBase(const std::string... | When is that "return parent" case reached? | if (IsStack(strPath))
{
strCheck = strDirectory;
RemoveSlashAtEnd(strCheck);
if (GetFileName(strCheck).size() == 3 && StringUtils::StartsWithNoCase(GetFileName(strCheck), "cd"))
strDirectory = GetDirectory(strCheck);
}
return strDirectory;
}
std::string URIUtils::GetDiscBase(const std::string... | @@ -455,20 +455,46 @@ std::string URIUtils::GetBasePath(const std::string& strPath)
return strDirectory;
}
+std::string URIUtils::GetDiscBase(const std::string& file)
+{
+ std::string discFile;
+ if (IsBluray(file))
+ discFile = GetBlurayFile(file);
+ else
+ discFile = file;
+
+ std::string parent{GetPa... | xbmc/utils/URIUtils.cpp | 26 | C++ | 0.071 | question | 42 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
auto end = std::chrono::steady_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
CLog::LogF(LOGDEBUG, "measured {} ms to extract thumb from file <{}> in {} packets. ",
duration.count(), redactPath, packetsTried);
return result;
}
bool CDVDFileInfo:... | What is the benefit? item.IsBluray() is relatively more expensive because indirectly uses GetOpticalMediaPath() which uses disk i/o.
CanExtract is used by the library scanner and can call this function many times. Small differences add up. |
auto end = std::chrono::steady_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
CLog::LogF(LOGDEBUG, "measured {} ms to extract thumb from file <{}> in {} packets. ",
duration.count(), redactPath, packetsTried);
return result;
}
bool CDVDFileInfo:... | @@ -267,8 +267,8 @@ bool CDVDFileInfo::CanExtract(const CFileItem& fileItem)
return false;
// mostly can't extract from discs and files from discs.
- if (URIUtils::IsBlurayPath(fileItem.GetPath()) || VIDEO::IsBDFile(fileItem) || fileItem.IsDVD() ||
- fileItem.IsDiscImage() || VIDEO::IsDVDFile(fileItem, ... | xbmc/cores/VideoPlayer/DVDFileInfo.cpp | 26 | C++ | 0.571 | performance | 240 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
sql += PrepareSQL(" WHERE idSeason=%i", idSeason);
m_pDS->exec(sql.c_str());
CommitTransaction();
return idSeason;
}
catch (...)
{
CLog::Log(LOGERROR, "{} ({}) failed", __FUNCTION__, idSeason);
}
RollbackTransaction();
return -1;
}
bool CVideoDatabase::SetFileForEpisode(const std::stri... | Please handle the return code. Same for SetFileForMovie. | sql += PrepareSQL(" WHERE idSeason=%i", idSeason);
m_pDS->exec(sql.c_str());
CommitTransaction();
return idSeason;
}
catch (...)
{
CLog::Log(LOGERROR, "{} ({}) failed", __FUNCTION__, idSeason);
}
RollbackTransaction();
return -1;
}
bool CVideoDatabase::SetFileForEpisode(const std::stri... | @@ -3017,13 +3018,18 @@ int CVideoDatabase::SetDetailsForSeason(const CVideoInfoTag& details, const std:
return -1;
}
-bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpisode, int idFile)
+bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpisode, int oldIdF... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.429 | suggestion | 56 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
{
std::string sql = PrepareSQL("UPDATE movie SET idFile=%i WHERE idFile=%i AND idMovie=%i",
idFile, oldIdFile, idMovie);
m_pDS->exec(sql);
sql = PrepareSQL(
"UPDATE videoversion SET idFile=%i WHERE idFile=%i AND media_type='movie' AND idMedia=%i",
idFile, ... | please log the rest of the parameters | std::string sql = PrepareSQL("UPDATE movie SET idFile=%i WHERE idFile=%i AND idMovie=%i",
idFile, oldIdFile, idMovie);
m_pDS->exec(sql);
sql = PrepareSQL(
"UPDATE videoversion SET idFile=%i WHERE idFile=%i AND media_type='movie' AND idMedia=%i",
idFile, oldI... | @@ -3034,24 +3040,89 @@ bool CVideoDatabase::SetFileForEpisode(const std::string& fileAndPath, int idEpi
return false;
}
-bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int idFile)
+bool CVideoDatabase::SetFileForMovie(const std::string& fileAndPath, int idMovie, int oldIdFile)
... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.071 | suggestion | 37 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
// BDMV
return AddFileToFolder(url2.Get(), "BDMV", "index.bdmv");
}
return std::string{};
}
std::string URLEncodePath(const std::string& strPath)
{
std::vector<std::string> segments = StringUtils::Split(strPath, "/");
for (std::vector<std::string>::iterator i = segments.begin(); i != segments.end()... | seems redundant with the IsBluray(path) earlier? | RemoveSlashAtEnd(parentFolder);
parentFolder = GetFileName(parentFolder);
if (StringUtils::EqualsNoCase(parentFolder, "VIDEO_TS") ||
StringUtils::EqualsNoCase(parentFolder, "BDMV"))
return GetParentPath(parent); // go back up another one
return parent;
}
std::string URIUtils::GetDiscBasePath(const st... | @@ -455,6 +455,22 @@ std::string URIUtils::GetBasePath(const std::string& strPath)
return strDirectory;
}
+std::string URIUtils::GetBlurayFile(const std::string& path)
+{
+ if (IsBluray(path))
+ {
+ const CURL url(path);
+ const CURL url2(url.GetHostName()); // strip bluray://
+ if (url2.IsProtocol("ud... | xbmc/utils/URIUtils.cpp | 26 | C++ | 0.071 | question | 48 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
#else
/* Get our PID and build the name of the link in /proc */
pid_t pid = getpid();
char linkname[64]; /* /proc/<pid>/exe */
snprintf(linkname, sizeof(linkname), "/proc/%i/exe", pid);
/* Now read the symbolic link */
char buf[PATH_MAX + 1];
buf[0] = 0;
int ret = readlink(linkname, buf, sizeof(buf) -... | Why modify this function? It seems to be used only when looking for external subs or audio, neither of which makes much sense for iso or bluray/dvd folders? | char linkname[64]; /* /proc/<pid>/exe */
snprintf(linkname, sizeof(linkname), "/proc/%i/exe", pid);
/* Now read the symbolic link */
char buf[PATH_MAX + 1];
buf[0] = 0;
int ret = readlink(linkname, buf, sizeof(buf) - 1);
if (ret != -1)
buf[ret] = 0;
strExecutablePath = buf;
#endif
return strExe... | @@ -1901,30 +1901,27 @@ std::string CUtil::GetFrameworksPath(bool forPython)
return strFrameworksPath;
}
-void CUtil::GetVideoBasePathAndFileName(const std::string& videoPath, std::string& basePath, std::string& videoFileName)
+void CUtil::GetVideoBasePathAndFileName(const std::string& videoPath, | xbmc/Util.cpp | 26 | C++ | 0.5 | question | 156 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
#include "video/VideoFileItemClassify.h"
#include "video/VideoInfoTag.h"
#include <memory>
using namespace KODI;
CApplicationPlayerCallback::CApplicationPlayerCallback()
{
}
void CApplicationPlayerCallback::OnPlayBackEnded()
{
CLog::LogF(LOGDEBUG, "CApplicationPlayerCallback::OnPlayBackEnded");
CGUIMessage msg... | this one is not simply a rename? does it fix something? | #include "video/VideoFileItemClassify.h"
#include "video/VideoInfoTag.h"
#include <memory>
using namespace KODI;
CApplicationPlayerCallback::CApplicationPlayerCallback()
{
}
void CApplicationPlayerCallback::OnPlayBackEnded()
{
CLog::LogF(LOGDEBUG, "CApplicationPlayerCallback::OnPlayBackEnded");
CGUIMessage msg... | @@ -58,7 +58,7 @@ void CApplicationPlayerCallback::OnPlayBackStarted(const CFileItem& file)
std::shared_ptr<CFileItem> itemCurrentFile;
// check if VideoPlayer should set file item stream details from its current streams
- const bool isBlu_dvd_image_or_stream = URIUtils::IsBluray(file.GetPath()) ||
+ const bo... | xbmc/application/ApplicationPlayerCallback.cpp | 26 | C++ | 0.357 | question | 55 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
{
std::string name2(strMovieName);
URIUtils::GetParentPath(name2,strMovieName);
if (URIUtils::IsInArchive(m_strPath))
{
// Try to get archive itself, if empty take path before
name2 = CURL(m_strPath).GetHostName();
if (name2.empty())
name2 = strMovieName;
URIUtils::Get... | This line is supposed to be in the previous commit. | std::string name2(strMovieName);
URIUtils::GetParentPath(name2,strMovieName);
if (URIUtils::IsInArchive(m_strPath))
{
// Try to get archive itself, if empty take path before
name2 = CURL(m_strPath).GetHostName();
if (name2.empty())
name2 = strMovieName;
URIUtils::GetPare... | @@ -2012,8 +2012,8 @@ std::string CFileItem::GetLocalMetadataPath() const
if (m_bIsFolder && !IsFileFolder())
return m_strPath;
- if (URIUtils::IsBluray(this->GetDynPath()) || VIDEO::IsDVDFile(*this) || VIDEO::IsBDFile(*this))
- return URIUtils::GetDiscBasePath(this->GetDynPath());
+ if (URIUtils::IsBlur... | xbmc/FileItem.cpp | 26 | C++ | 0.143 | suggestion | 51 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
std::string CUtil::GetFrameworksPath(bool forPython)
{
std::string strFrameworksPath;
#if defined(TARGET_DARWIN)
strFrameworksPath = CDarwinUtils::GetFrameworkPath(forPython);
#endif
return strFrameworksPath;
}
void CUtil::GetVideoBasePathAndFileName(const std::string& videoPath,
... | problem carried over from master code: unnecessary because a new CFileItem doesn't have a populated videoinfotag. That makes the following if (basePath.empty()) unnecessary as well. | #if defined(TARGET_DARWIN)
strFrameworksPath = CDarwinUtils::GetFrameworkPath(forPython);
#endif
return strFrameworksPath;
}
void CUtil::GetVideoBasePathAndFileName(const std::string& videoPath,
std::string& basePath,
std::string& vide... | @@ -1901,30 +1901,27 @@ std::string CUtil::GetFrameworksPath(bool forPython)
return strFrameworksPath;
}
-void CUtil::GetVideoBasePathAndFileName(const std::string& videoPath, std::string& basePath, std::string& videoFileName)
+void CUtil::GetVideoBasePathAndFileName(const std::string& videoPath,
+ ... | xbmc/Util.cpp | 26 | C++ | 0.5 | suggestion | 181 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
return true;
}
bool CGUIDialogVideoInfo::DeleteVideoItem(const std::shared_ptr<CFileItem>& item,
bool unavailable /* = false */)
{
if (item == nullptr)
return false;
// delete the video item from the database
if (!DeleteVideoItemFromDatabase(item, unavailable))
... | The change makes this more complex, which is unavoidable when all that's available is a string path, but at this point, a videoinfotag exists and maybe the m_basePath member could help do this more efficiently? The library scanner should have done most if not all of the work already. I haven't looked at it in depth tho... | }
bool CGUIDialogVideoInfo::DeleteVideoItem(const std::shared_ptr<CFileItem>& item,
bool unavailable /* = false */)
{
if (item == nullptr)
return false;
// delete the video item from the database
if (!DeleteVideoItemFromDatabase(item, unavailable))
return false;... | @@ -1416,15 +1416,8 @@ bool CGUIDialogVideoInfo::DeleteVideoItem(const std::shared_ptr<CFileItem>& item
{
std::string strDeletePath = item->GetVideoInfoTag()->GetPath();
- if (StringUtils::EqualsNoCase(URIUtils::GetFileName(strDeletePath), "VIDEO_TS.IFO"))
- {
- strDeletePath = URIUtils::GetDirecto... | xbmc/video/dialogs/GUIDialogVideoInfo.cpp | 26 | C++ | 0.643 | performance | 498 | 51 | 51 | false | [VideoDatabase][VideoVersions] Various fixes for bluray:// paths (library related) and associated code refactoring (1/4). | 26,220 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
}
/* close both files */
newFile.Close();
file.Close();
/* verify that we managed to completed the file */
if (llFileSize && llPos != llFileSize)
{
CFile::Delete(dest);
return false;
}
return true;
}
return false;
}
//***********************************************... | `XFILE` was removed everywhere else in the filesystem subdir, might as well remove it here too for consistency. | }
/* close both files */
newFile.Close();
file.Close();
/* verify that we managed to completed the file */
if (llFileSize && llPos != llFileSize)
{
CFile::Delete(dest);
return false;
}
return true;
}
return false;
}
//***********************************************... | @@ -205,22 +205,22 @@ bool CFile::CURLCreate(const std::string &url)
return true;
}
-bool CFile::CURLAddOption(XFILE::CURLOPTIONTYPE type, const char* name, const char * value)
+bool CFile::CURLAddOption(XFILE::CURLOptionType type, const char* name, const char * value) | xbmc/filesystem/File.cpp | 26 | C++ | 0.714 | style | 111 | 51 | 51 | false | XFILE::CURLOptionType: convert to enum class | 26,223 | xbmc/xbmc | 17,740 | C++ | garbear | notspiff |
return true;
}
int CSMBDirectory::Open(const CURL &url)
{
smb.Init();
std::string strAuth;
return OpenDir(url, strAuth);
}
/// \brief Checks authentication against SAMBA share and prompts for username and password if needed
/// \param strAuth The SMB style path
/// \return SMB file descriptor
int CSMBDirector... | Perhaps only check for empty username? | return true;
}
int CSMBDirectory::Open(const CURL &url)
{
smb.Init();
std::string strAuth;
return OpenDir(url, strAuth);
}
/// \brief Checks authentication against SAMBA share and prompts for username and password if needed
/// \param strAuth The SMB style path
/// \return SMB file descriptor
int CSMBDirector... | @@ -259,11 +259,22 @@ int CSMBDirectory::Open(const CURL &url)
int CSMBDirectory::OpenDir(const CURL& url, std::string& strAuth)
{
int fd = -1;
+ bool guest = false;
/* make a writeable copy */
CURL urlIn = CSMB::GetResolvedUrl(url);
CPasswordManager::GetInstance().AuthenticateURL(urlIn);
+
+ // set... | xbmc/platform/posix/filesystem/SMBDirectory.cpp | 26 | C++ | 0.286 | question | 38 | 51 | 51 | false | [FileSystem][POSIX] Fix SMB passwordless access (POSIX client - Windows server) | 26,238 | xbmc/xbmc | 17,740 | C++ | arnova | thexai |
InfoRet RetrieveInfoForTvShow(CFileItem* pItem,
bool bDirNames,
ADDON::ScraperPtr& scraper,
bool useLocal,
CScraperUrl* pURL,
bool fetchEpisodes,... | Grammar suggestion: `alreadyHasArt` |
InfoRet RetrieveInfoForTvShow(CFileItem* pItem,
bool bDirNames,
ADDON::ScraperPtr& scraper,
bool useLocal,
CScraperUrl* pURL,
bool fetchEpisodes,... | @@ -133,7 +133,8 @@ namespace KODI::VIDEO
long showID,
const ADDON::ScraperPtr& scraper,
bool useLocal,
- CGUIDialogProgress* progress = nullptr);
+ ... | xbmc/video/VideoInfoScanner.h | 26 | C/C++ | 0.5 | suggestion | 35 | 51 | 51 | false | [VideoInfoScanner] Avoid duplicate calls to scraper to get season art | 26,252 | xbmc/xbmc | 17,740 | C++ | garbear | 78andyp |
return InfoRet::NOT_NEEDED;
if (m_bStop || (progress && progress->IsCanceled()))
return InfoRet::CANCELLED;
CVideoInfoTag showInfo;
m_database.GetTvShowInfo("", showInfo, showID);
InfoRet ret = OnProcessSeriesFolder(files, scraper, useLocal, showInfo, progress);
if (ret == InfoRet::AD... | You could write this in a single statement:
```cpp
const bool updateSeasonArt =
alreadyHasArt || std::ranges::any_of(seasonArt, [](auto& i) { return i.second.empty(); });
```
This way you can make `updateSeasonArt` const and it's also easier to read (in my opinion at least :wink: ). | return InfoRet::NOT_NEEDED;
if (m_bStop || (progress && progress->IsCanceled()))
return InfoRet::CANCELLED;
CVideoInfoTag showInfo;
m_database.GetTvShowInfo("", showInfo, showID);
InfoRet ret = OnProcessSeriesFolder(files, scraper, useLocal, showInfo, progress);
if (ret == InfoRet::AD... | @@ -925,19 +927,22 @@ CVideoInfoScanner::CVideoInfoScanner()
std::map<int, std::map<std::string, std::string>> seasonArt;
m_database.GetTvShowSeasonArt(showID, seasonArt);
- bool updateSeasonArt = false;
- for (std::map<int, std::map<std::string, std::string>>::const_iterator i = seasonArt.beg... | xbmc/video/VideoInfoScanner.cpp | 26 | C++ | 1 | suggestion | 306 | 51 | 51 | false | [VideoInfoScanner] Avoid duplicate calls to scraper to get season art | 26,252 | xbmc/xbmc | 17,740 | C++ | neo1973 | 78andyp |
int movieYear = -1; // hint that movie title was not found
if (result == InfoType::TITLE)
{
CVideoInfoTag* tag = pItem->GetVideoInfoTag();
movieTitle = tag->GetTitle();
movieYear = tag->GetYear(); // movieYear is expected to be >= 0
}
std::string identifierType;
std::string id... | I know I'm late to the party, but from only reading this line, who could tell what this newly introduced `true`means? That's why I'm trying to avoid bool params, knowing that introducing an enum class to model the two possible values is a bit more work, but produces far more readable code. @78andyp
Same applies for ... | int movieYear = -1; // hint that movie title was not found
if (result == InfoType::TITLE)
{
CVideoInfoTag* tag = pItem->GetVideoInfoTag();
movieTitle = tag->GetTitle();
movieYear = tag->GetYear(); // movieYear is expected to be >= 0
}
std::string identifierType;
std::string id... | @@ -682,7 +682,8 @@ CVideoInfoScanner::CVideoInfoScanner()
if (fetchEpisodes)
{
- InfoRet ret = RetrieveInfoForEpisodes(pItem, lResult, info2, useLocal, pDlgProgress);
+ InfoRet ret =
+ RetrieveInfoForEpisodes(pItem, lResult, info2, useLocal, pDlgProgress, true); | xbmc/video/VideoInfoScanner.cpp | 26 | C++ | 0.857 | suggestion | 581 | 51 | 51 | false | [VideoInfoScanner] Avoid duplicate calls to scraper to get season art | 26,252 | xbmc/xbmc | 17,740 | C++ | ksooo | 78andyp |
#include <limits.h>
#ifndef SIZE_MAX
#define SIZE_MAX UINTPTR_MAX
#endif // ! SIZE_MAX
#ifndef SSIZE_MAX
#define SSIZE_MAX INTPTR_MAX
#endif // ! SSIZE_MAX
#endif // ! SIZE_MAX || ! SSIZE_MAX
#include "IFileTypes.h"
class CURL;
namespace XFILE
{
class IFile
{
public:
IFile();
virtual ~IFile();
virtual bool O... | Can this change be avoided? We shouldn't need to update the interface, as that affects like 50 implementations. | #include <limits.h>
#ifndef SIZE_MAX
#define SIZE_MAX UINTPTR_MAX
#endif // ! SIZE_MAX
#ifndef SSIZE_MAX
#define SSIZE_MAX INTPTR_MAX
#endif // ! SSIZE_MAX
#endif // ! SIZE_MAX || ! SSIZE_MAX
#include "IFileTypes.h"
class CURL;
namespace XFILE
{
class IFile
{
public:
IFile();
virtual ~IFile();
virtual bool O... | @@ -48,7 +48,7 @@ class IFile
virtual bool Open(const CURL& url) = 0;
virtual bool OpenForWrite(const CURL& url, bool bOverWrite = false) { return false; }
virtual bool ReOpen(const CURL& url) { return false; }
- virtual bool Exists(const CURL& url) = 0;
+ virtual bool Exists(const CURL& url) { return false;... | xbmc/filesystem/IFile.h | 26 | C/C++ | 0.5 | suggestion | 111 | 51 | 51 | false | [Video] Various fixes for bluray:// paths (menu and information related) and associated code refactoring (2/4). | 26,273 | xbmc/xbmc | 17,740 | C++ | garbear | 78andyp |
bool CBlurayDirectory::GetDirectory(const CURL& url, CFileItemList &items)
{
Dispose();
m_url = url;
std::string root = m_url.GetHostName();
std::string file = m_url.GetFileName();
URIUtils::RemoveSlashAtEnd(file);
URIUtils::RemoveSlashAtEnd(root);
if (!InitializeBluray(root))
return false;
if(fi... | Not a blocker, but if you wrap comments at 80 characters it makes it easier to read for developers that need large fonts or have small screens. |
bool CBlurayDirectory::GetDirectory(const CURL& url, CFileItemList &items)
{
Dispose();
m_url = url;
std::string root = m_url.GetHostName();
std::string file = m_url.GetFileName();
URIUtils::RemoveSlashAtEnd(file);
URIUtils::RemoveSlashAtEnd(root);
if (!InitializeBluray(root))
return false;
if(fi... | @@ -235,6 +235,21 @@ bool CBlurayDirectory::GetDirectory(const CURL& url, CFileItemList &items)
hints.flags = m_flags;
if (!CDirectory::GetDirectory(url2, items, hints))
return false;
+
+ // Found items will have underlying protocol (eg. udf:// or smb://) in path so add back bluray:// | xbmc/filesystem/BlurayDirectory.cpp | 26 | C++ | 0.286 | suggestion | 143 | 51 | 51 | false | [Video] Various fixes for bluray:// paths (menu and information related) and associated code refactoring (2/4). | 26,273 | xbmc/xbmc | 17,740 | C++ | garbear | 78andyp |
TagLib::ByteVector readBlock(size_t length) override;
#else
TagLib::ByteVector readBlock(TagLib::ulong length) override;
#endif
/*!
* Attempts to write the block \a data at the current get pointer. If the
* file is currently only opened read only -- i.e. readOnly() returns true --
* this at... | Why? This was correct as it was:
https://github.com/taglib/taglib/blob/648f5e588209464702e4955de614e391d3768ec8/taglib/toolkit/tiostream.h#L117-L118 | TagLib::ByteVector readBlock(size_t length) override;
#else
TagLib::ByteVector readBlock(TagLib::ulong length) override;
#endif
/*!
* Attempts to write the block \a data at the current get pointer. If the
* file is currently only opened read only -- i.e. readOnly() returns true --
* this at... | @@ -63,7 +63,7 @@ namespace MUSIC_INFO
*/
#if (TAGLIB_MAJOR_VERSION >= 2)
void insert(const TagLib::ByteVector& data,
- TagLib::offset_t start = 0,
+ off_t start = 0, | xbmc/music/tags/TagLibVFSStream.h | 26 | C/C++ | 0.286 | question | 149 | 51 | 51 | false | Fix build with taglib2 | 26,278 | xbmc/xbmc | 17,740 | C++ | neo1973 | basilgello |
return CDirectory::Exists(path) ? path : "";
}
void CVideoInfoScanner::AddLocalItemArtwork(CGUIListItem::ArtMap& itemArt,
const std::vector<std::string>& wantedArtTypes, const std::string& itemPath,
bool addAll, bool exactName)
{
std::string path = URIUtils::GetDirectory(itemPath);
if (path.e... | It wouldn't hurt to make this `const`. | return CDirectory::Exists(path) ? path : "";
}
void CVideoInfoScanner::AddLocalItemArtwork(CGUIListItem::ArtMap& itemArt,
const std::vector<std::string>& wantedArtTypes, const std::string& itemPath,
bool addAll, bool exactName)
{
std::string path = URIUtils::GetDirectory(itemPath);
if (path.e... | @@ -1722,12 +1722,21 @@ CVideoInfoScanner::~CVideoInfoScanner()
baseFilename.append("-");
}
+ bool caseSensitive{CServiceBroker::GetSettingsComponent()
+ ->GetAdvancedSettings()
+ ->m_bCaseSensitiveLocalArtMatch}; | xbmc/video/VideoInfoScanner.cpp | 26 | C++ | 0.286 | suggestion | 38 | 51 | 51 | false | [Library] Fix #26236 - Address file name case sensitivity issues during local art scraping and export. | 26,291 | xbmc/xbmc | 17,740 | C++ | neo1973 | 78andyp |
return;
CFileItemList availableArtFiles;
CDirectory::GetDirectory(path, availableArtFiles,
CServiceBroker::GetFileExtensionProvider().GetPictureExtensions(),
DIR_FLAG_NO_FILE_DIRS | DIR_FLAG_READ_CACHE | DIR_FLAG_NO_FILE_INFO);
std::string baseFilename = URIUtils::GetFileName(itemPat... | Maybe change this into a single statement?
```suggestion
const bool matchesFilename = !baseFilename.empty() && caseSensitive
? StringUtils::StartsWith(candidate, baseFilename)
: StringUtils::StartsWithNoCase(candidate, baseFilenam... | return;
CFileItemList availableArtFiles;
CDirectory::GetDirectory(path, availableArtFiles,
CServiceBroker::GetFileExtensionProvider().GetPictureExtensions(),
DIR_FLAG_NO_FILE_DIRS | DIR_FLAG_READ_CACHE | DIR_FLAG_NO_FILE_INFO);
std::string baseFilename = URIUtils::GetFileName(itemPat... | @@ -1722,12 +1722,21 @@ CVideoInfoScanner::~CVideoInfoScanner()
baseFilename.append("-");
}
+ bool caseSensitive{CServiceBroker::GetSettingsComponent()
+ ->GetAdvancedSettings()
+ ->m_bCaseSensitiveLocalArtMatch};
+
for (const auto& artFile : ava... | xbmc/video/VideoInfoScanner.cpp | 26 | C++ | 1 | security | 330 | 51 | 51 | false | [Library] Fix #26236 - Address file name case sensitivity issues during local art scraping and export. | 26,291 | xbmc/xbmc | 17,740 | C++ | neo1973 | 78andyp |
int m_iMusicLibraryRecentlyAddedItems;
int m_iMusicLibraryDateAdded;
bool m_bMusicLibraryAllItemsOnBottom;
bool m_bMusicLibraryCleanOnUpdate;
bool m_bMusicLibraryArtistSortOnUpdate;
bool m_bMusicLibraryUseISODates;
bool m_bMusicLibraryArtistNavigatesToSongs;
std::string m_strMusicLibrar... | Please default init the member variable here. => https://github.com/xbmc/xbmc/blob/master/docs/CODE_GUIDELINES.md#114-default-member-initialization
Please fix the name of the member variable (no type prefix). => https://github.com/xbmc/xbmc/blob/master/docs/CODE_GUIDELINES.md#88-variables |
int m_iMusicLibraryRecentlyAddedItems;
int m_iMusicLibraryDateAdded;
bool m_bMusicLibraryAllItemsOnBottom;
bool m_bMusicLibraryCleanOnUpdate;
bool m_bMusicLibraryArtistSortOnUpdate;
bool m_bMusicLibraryUseISODates;
bool m_bMusicLibraryArtistNavigatesToSongs;
std::string m_strMusicLibrar... | @@ -269,6 +269,8 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler
bool m_bVideoScannerIgnoreErrors;
int m_iVideoLibraryDateAdded;
+ bool m_bCaseSensitiveLocalArtMatch; | xbmc/settings/AdvancedSettings.h | 26 | C/C++ | 0.643 | nitpick | 292 | 51 | 51 | false | [Library] Fix #26236 - Address file name case sensitivity issues during local art scraping and export. | 26,291 | xbmc/xbmc | 17,740 | C++ | ksooo | 78andyp |
const int end_time_mka_file = m_fctx->duration * av_q2d(av_get_time_base_q());
AVDictionaryEntry* tag=nullptr;
while ((tag = av_dict_get(m_fctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
{
if (StringUtils::CompareNoCase(tag->key, "title") == 0)
title = tag->value;
else if (StringUtils::CompareN... | doesn't get the split/join treatment? separate separators/advanced setting for audiobooks needed? | std::vector<std::string> artistsort;
std::vector<std::string> tagdata;
std::vector<std::string> separators{" feat. ", " ft. ", " Feat. ", " Ft. ", ";", ":",
"|", "#", "/", " with ", "&"};
const std::string musicsep =
CServiceBroker::GetSettingsCompone... | @@ -55,20 +57,108 @@ bool CAudioBookFileDirectory::GetDirectory(const CURL& url,
std::string title;
std::string author;
std::string album;
+ std::string desc;
+ std::vector<std::string> artistsort;
+ std::vector<std::string> tagdata;
+ std::vector<std::string> separators{" feat. ", " ft. ", " Feat. ", " Ft... | xbmc/filesystem/AudioBookFileDirectory.cpp | 26 | C++ | 0.143 | question | 97 | 51 | 51 | false | [MUISIC]]MKA FILES] Use ffmpeg to read more tags from mka files | 26,293 | xbmc/xbmc | 17,740 | C++ | CrystalP | the-black-eagle |
{
av_free(m_ioctx->buffer);
av_free(m_ioctx);
}
}
bool CAudioBookFileDirectory::GetDirectory(const CURL& url,
CFileItemList &items)
{
if (!m_fctx && !ContainsFiles(url))
return true;
std::string title;
std::string author;
std::string album;
const i... | I don't think the default item separator of " / " (and similar patterns with whitespace in the item separator) works correctly and round-trips strings.
ex multiple artists "a / b", split as "a " " b", because the "/" separator is used, then joined back together with " / " as "a / b" (extra spaces not easy to see wit... | avformat_close_input(&m_fctx);
if (m_ioctx)
{
av_free(m_ioctx->buffer);
av_free(m_ioctx);
}
}
bool CAudioBookFileDirectory::GetDirectory(const CURL& url,
CFileItemList &items)
{
if (!m_fctx && !ContainsFiles(url))
return true;
std::string title;
s... | @@ -55,20 +57,108 @@ bool CAudioBookFileDirectory::GetDirectory(const CURL& url,
std::string title;
std::string author;
std::string album;
+ std::string desc;
+ std::vector<std::string> artistsort;
+ std::vector<std::string> tagdata;
+ std::vector<std::string> separators{" feat. ", " ft. ", " Feat. ", " Ft... | xbmc/filesystem/AudioBookFileDirectory.cpp | 26 | C++ | 0.643 | suggestion | 968 | 51 | 51 | false | [MUISIC]]MKA FILES] Use ffmpeg to read more tags from mka files | 26,293 | xbmc/xbmc | 17,740 | C++ | CrystalP | the-black-eagle |
{
item->SetEndOffset(CUtil::ConvertSecsToMilliSecs(end_time_mka_file)); // mka file
if (item->GetEndOffset() < 0)
item->SetEndOffset(CUtil::ConvertSecsToMilliSecs(end_time_m4b_file)); // m4b file
}
}
item->GetMusicInfoTag()->SetDuration(
CUtil::ConvertMilliSecsToSec... | feels like temp code left in? do artists separators make sense here? | albumtag.SetAlbumArtist(tag->value);
else if (key == "MUSICBRAINZ_ALBUMID")
albumtag.SetMusicBrainzAlbumID(tag->value);
else if (key == "MUSICBRAINZ_RELEASEGROUPID")
albumtag.SetMusicBrainzReleaseGroupID(tag->value);
else if (key == "MUSICBRAINZ_ALBUMSTATUS")
albumtag.S... | @@ -55,20 +57,108 @@ bool CAudioBookFileDirectory::GetDirectory(const CURL& url,
std::string title;
std::string author;
std::string album;
+ std::string desc;
+ std::vector<std::string> artistsort;
+ std::vector<std::string> tagdata;
+ std::vector<std::string> separators{" feat. ", " ft. ", " Feat. ", " Ft... | xbmc/filesystem/AudioBookFileDirectory.cpp | 26 | C++ | 0.143 | question | 68 | 51 | 51 | false | [MUISIC]]MKA FILES] Use ffmpeg to read more tags from mka files | 26,293 | xbmc/xbmc | 17,740 | C++ | CrystalP | the-black-eagle |
/*
* Copyright (C) 2014 Arne Morten Kvarving
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "AudioBookFileDirectory.h"
#include "FileItem.h"
#include "FileItemList.h"
#include "URL.h"
#include "Util.h"
#include "cores/FFmpeg.h"
#include "filesystem/Fil... | same as genre, maybe a more generic list of separators would be more appropriate here.
probably applies to involved people and a few other places as well. | albumtag.SetDiscSubtitle(tag->value);
else if (key == "REMIXED_BY")
albumtag.AddArtistRole("Remixer", tag->value);
else if (key == "COMMENT")
albumtag.SetComment(tag->value);
}
}
std::string thumb;
if (m_fctx->nb_chapters > 1)
thumb = IMAGE_FILES::URLFromFile(url.Get()... | @@ -81,29 +171,101 @@ bool CAudioBookFileDirectory::GetDirectory(const CURL& url,
std::string chaptitle = StringUtils::Format(g_localizeStrings.Get(25010), i + 1);
std::string chapauthor;
std::string chapalbum;
+
+ std::shared_ptr<CFileItem> item(new CFileItem(url.Get(), false));
+ *item->GetMusicI... | xbmc/filesystem/AudioBookFileDirectory.cpp | 26 | C++ | 0.286 | suggestion | 155 | 180 | 51 | false | [MUISIC]]MKA FILES] Use ffmpeg to read more tags from mka files | 26,293 | xbmc/xbmc | 17,740 | C++ | CrystalP | the-black-eagle |
/*
* Copyright (C) 2014 Arne Morten Kvarving
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "AudioBookFileDirectory.h"
#include "FileItem.h"
#include "FileItemList.h"
#include "URL.h"
#include "Util.h"
#include "cores/FFmpeg.h"
#include "filesystem/Fil... | Naming? This seems specific to roles. | if (item->GetEndOffset() < 0 ||
item->GetEndOffset() > CUtil::ConvertMilliSecsToSecs(m_fctx->duration))
{
if (i < m_fctx->nb_chapters - 1)
item->SetEndOffset(CUtil::ConvertSecsToMilliSecs(
m_fctx->chapters[i + 1]->start * av_q2d(m_fctx->chapters[i + 1]->time_base)));
else... | @@ -137,6 +299,25 @@ bool CAudioBookFileDirectory::GetDirectory(const CURL& url,
return true;
}
+void CAudioBookFileDirectory::AddCommaDelimitedString(const std::vector<std::string>& data, | xbmc/filesystem/AudioBookFileDirectory.cpp | 26 | C++ | 0.071 | style | 37 | 180 | 51 | false | [MUISIC]]MKA FILES] Use ffmpeg to read more tags from mka files | 26,293 | xbmc/xbmc | 17,740 | C++ | CrystalP | the-black-eagle |
/*
* Copyright (C) 2014 Arne Morten Kvarving
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "IFileDirectory.h"
extern "C" {
#include <libavformat/avformat.h>
}
namespace XFILE
{
class CAudioBookFileDirectory : public IFileDirectory
{
... | unrelated to the PR but for some reason that header is not included in cmake? | /*
* Copyright (C) 2014 Arne Morten Kvarving
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "IFileDirectory.h"
#include "music/tags/MusicInfoTag.h"
#include <memory>
extern "C" {
#include <libavformat/avformat.h>
}
namespace XFILE
{
cl... | @@ -8,10 +8,13 @@
#pragma once
#include "IFileDirectory.h"
+#include "music/tags/MusicInfoTag.h" | xbmc/filesystem/AudioBookFileDirectory.h | 11 | C/C++ | 0.143 | question | 77 | 31 | 36 | false | [MUISIC]]MKA FILES] Use ffmpeg to read more tags from mka files | 26,293 | xbmc/xbmc | 17,740 | C++ | CrystalP | the-black-eagle |
/*
* Copyright (C) 2014 Arne Morten Kvarving
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "IFileDirectory.h"
extern "C" {
#include <libavformat/avformat.h>
}
namespace XFILE
{
class CAudioBookFileDirectory : public IFileDirectory
{
... | static? or probably better in an anonymous namespace of AudioBookFileDirectory.cpp, |
#pragma once
#include "IFileDirectory.h"
#include "music/tags/MusicInfoTag.h"
#include <memory>
extern "C" {
#include <libavformat/avformat.h>
}
namespace XFILE
{
class CAudioBookFileDirectory : public IFileDirectory
{
public:
~CAudioBookFileDirectory(void) override;
bool GetDirectory(const CURL... | @@ -24,6 +27,9 @@ namespace XFILE
bool IsAllowed(const CURL& url) const override { return true; }
protected:
+ void AddCommaDelimitedString(const std::vector<std::string>& data,
+ const std::vector<std::string>& separators,
+ MUSIC_I... | xbmc/filesystem/AudioBookFileDirectory.h | 26 | C/C++ | 0.357 | suggestion | 83 | 31 | 31 | false | [MUISIC]]MKA FILES] Use ffmpeg to read more tags from mka files | 26,293 | xbmc/xbmc | 17,740 | C++ | CrystalP | the-black-eagle |
}
if (PLAYLIST::IsPlayList(item))
return false;
// Translate/Resolve the url if needed - recursively, but only limited times.
static constexpr size_t MAX_ITEM_RESOLVE_ATTEMPTS{5};
std::string lastDynPath{item.GetDynPath()};
size_t itemResolveAttempt{0};
while (itemResolveAttempt < MAX_ITEM_RESOLVE_... | Depending on how you feel about saving a copy:
```suggestion
std::string newDynPath{item.GetDynPath()};
if (newDynPath == lastDynPath)
break; // done
lastDynPath = std::move(newDynPath);
``` | }
if (PLAYLIST::IsPlayList(item))
return false;
// Translate/Resolve the url if needed - recursively, but only limited times.
std::string lastDynPath{item.GetDynPath()};
size_t itemResolveAttempt{0};
while (itemResolveAttempt < MAX_ITEM_RESOLVE_ATTEMPTS)
{
itemResolveAttempt++;
const std::u... | @@ -2331,11 +2331,27 @@ bool CApplication::PlayFile(CFileItem item,
if (PLAYLIST::IsPlayList(item))
return false;
- // Translate/Resolve the url if needed
- const std::unique_ptr<IDirectory> dir{CDirectoryFactory::Create(item)};
- if (dir && !dir->Resolve(item))
+ // Translate/Resolve the url if needed - ... | xbmc/application/Application.cpp | 26 | C++ | 1 | suggestion | 216 | 51 | 51 | false | [application] Fix playback of items which require multiple URL resolu… | 26,373 | xbmc/xbmc | 17,740 | C++ | neo1973 | ksooo |
const auto appPlayer = GetComponent<CApplicationPlayer>();
const auto stackHelper = GetComponent<CApplicationStackHelper>();
if (!bRestart)
{
// bRestart will be true when called from PlayStack(), skipping this block
appPlayer->SetPlaySpeed(1);
m_nextPlaylistItem = -1;
stackHelper->Clear();
... | Maybe we can place this somewhere else? I think the recursive item resolution is set to 5 in other places too |
const auto appPlayer = GetComponent<CApplicationPlayer>();
const auto stackHelper = GetComponent<CApplicationStackHelper>();
if (!bRestart)
{
// bRestart will be true when called from PlayStack(), skipping this block
appPlayer->SetPlaySpeed(1);
m_nextPlaylistItem = -1;
stackHelper->Clear();
... | @@ -2331,11 +2331,27 @@ bool CApplication::PlayFile(CFileItem item,
if (PLAYLIST::IsPlayList(item))
return false;
- // Translate/Resolve the url if needed
- const std::unique_ptr<IDirectory> dir{CDirectoryFactory::Create(item)};
- if (dir && !dir->Resolve(item))
+ // Translate/Resolve the url if needed - ... | xbmc/application/Application.cpp | 26 | C++ | 0.286 | suggestion | 109 | 51 | 51 | false | [application] Fix playback of items which require multiple URL resolu… | 26,373 | xbmc/xbmc | 17,740 | C++ | enen92 | ksooo |
void UpdateVideoFilter();
void CheckVideoParameters(int index);
AVColorPrimaries GetSrcPrimaries(AVColorPrimaries srcPrimaries, unsigned int width, unsigned int height);
// textures
virtual bool UploadTexture(int index);
virtual void DeleteTexture(int index);
virtual bool CreateTexture(int index);
boo... | I'm not a Linux/GL dev but doubt that was the intention. Best leave it alone if not sure of the replacement. Maybe it was meant to be renderer or rendering? | void UpdateVideoFilter();
void CheckVideoParameters(int index);
AVColorPrimaries GetSrcPrimaries(AVColorPrimaries srcPrimaries, unsigned int width, unsigned int height);
// textures
virtual bool UploadTexture(int index);
virtual void DeleteTexture(int index);
virtual bool CreateTexture(int index);
boo... | @@ -124,7 +124,7 @@ class CLinuxRendererGLES : public CBaseRenderer
void RenderFromFBO();
void RenderSinglePass(int index, int field); // single pass glsl renderer
- // hooks for HwDec Renderered
+ // hooks for HwDec Rendered | xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGLES.h | 26 | C/C++ | 0.5 | question | 156 | 51 | 51 | false | Fix typos found in xbmc/cores | 26,400 | xbmc/xbmc | 17,740 | C++ | CrystalP | luzpaz |
DXGI_HDR_METADATA_HDR10 hdr10 = {};
hdr10.RedPrimary[0] = 34000; // Display P3 primaries
hdr10.RedPrimary[1] = 16000;
hdr10.GreenPrimary[0] = 13250;
hdr10.GreenPrimary[1] = 34500;
hdr10.BluePrimary[0] = 7500;
hdr10.BluePrimary[1] = 3000;
hdr10.WhitePoint[0] = 15635;
... | ok but let's fix the comment not just the typo. I think it should be inside the if (m_AutoSwitchHDR) and something like
// color space already sdr or set by the swap chain re-creation | DXGI_HDR_METADATA_HDR10 hdr10 = {};
hdr10.RedPrimary[0] = 34000; // Display P3 primaries
hdr10.RedPrimary[1] = 16000;
hdr10.GreenPrimary[0] = 13250;
hdr10.GreenPrimary[1] = 34500;
hdr10.BluePrimary[0] = 7500;
hdr10.BluePrimary[1] = 3000;
hdr10.WhitePoint[0] = 15635;
... | @@ -653,7 +653,7 @@ void CRendererBase::ProcessHDR(CRenderBuffer* rb)
{
// Switch to SDR rendering
CLog::LogF(LOGINFO, "Switching to SDR rendering");
- // not need set color space because is alredy set when swap chain is re-created
+ // not need set color space because is already set when s... | xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererBase.cpp | 26 | C++ | 0.5 | suggestion | 184 | 51 | 51 | false | Fix typos found in xbmc/cores | 26,400 | xbmc/xbmc | 17,740 | C++ | CrystalP | luzpaz |
hdr10.GreenPrimary[0] = 13250;
hdr10.GreenPrimary[1] = 34500;
hdr10.BluePrimary[0] = 7500;
hdr10.BluePrimary[1] = 3000;
hdr10.WhitePoint[0] = 15635;
hdr10.WhitePoint[1] = 16450;
hdr10.MaxMasteringLuminance = 1000 * 10000; // 1000 nits
hdr10.MinMasteringLuminance = 50; // ... | ok for the text I was suggesting moving it where more appropriate
```suggestion
if (m_AutoSwitchHDR)
{
// color space already sdr or set by the swap chain re-creation
if (DX::Windowing()->IsHDROutput())
``` | hdr10.GreenPrimary[0] = 13250;
hdr10.GreenPrimary[1] = 34500;
hdr10.BluePrimary[0] = 7500;
hdr10.BluePrimary[1] = 3000;
hdr10.WhitePoint[0] = 15635;
hdr10.WhitePoint[1] = 16450;
hdr10.MaxMasteringLuminance = 1000 * 10000; // 1000 nits
hdr10.MinMasteringLuminance = 50; // ... | @@ -653,7 +653,7 @@ void CRendererBase::ProcessHDR(CRenderBuffer* rb)
{
// Switch to SDR rendering
CLog::LogF(LOGINFO, "Switching to SDR rendering");
- // not need set color space because is alredy set when swap chain is re-created
+ // color space already sdr or set by the swap chain re-cr... | xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererBase.cpp | 26 | C++ | 1 | suggestion | 240 | 51 | 51 | false | Fix typos found in xbmc/cores | 26,400 | xbmc/xbmc | 17,740 | C++ | CrystalP | luzpaz |
db.RemovePackage(package);
CFile::Delete(package);
ReportInstallError(m_addon->ID(), URIUtils::GetFileName(package));
return false;
}
installFrom = package;
}
}
m_currentType = CAddonInstallJob::TYPE_INSTALL;
// run any pre-install functions
ADDON::OnPreInstall... | I guess here "succeeded" was meant. | db.RemovePackage(package);
CFile::Delete(package);
ReportInstallError(m_addon->ID(), URIUtils::GetFileName(package));
return false;
}
installFrom = package;
}
}
m_currentType = CAddonInstallJob::TYPE_INSTALL;
// run any pre-install functions
ADDON::OnPreInstall... | @@ -805,7 +805,7 @@ bool CAddonInstallJob::DoWork()
if (!Install(installFrom, m_repo))
return false;
- // Load new installed and if successed replace defined m_addon here with new one
+ // Load new installed and if successful replace defined m_addon here with new one | xbmc/addons/AddonInstaller.cpp | 26 | C++ | 0.071 | suggestion | 35 | 51 | 51 | false | Fix typos found in various addons directories | 26,414 | xbmc/xbmc | 17,740 | C++ | ksooo | luzpaz |
/// @brief Check this is first created instance by Kodi.
bool FirstInstance() const { return m_instance->info->first_instance; }
///@}
operator KODI_ADDON_INSTANCE_STRUCT*() { return m_instance; }
operator KODI_ADDON_INSTANCE_STRUCT*() const { return m_instance; }
private:
IInstanceInfo() = delete;
II... | I think the author wants to state that this is some sort of internal class. I would simply remove the whole line as it adds no real value for the reader of this documentation. | /// @brief Check this is first created instance by Kodi.
bool FirstInstance() const { return m_instance->info->first_instance; }
///@}
operator KODI_ADDON_INSTANCE_STRUCT*() { return m_instance; }
operator KODI_ADDON_INSTANCE_STRUCT*() const { return m_instance; }
private:
IInstanceInfo() = delete;
II... | @@ -558,7 +558,7 @@ class ATTR_DLL_LOCAL IInstanceInfo
*
* Mainly is this currently used to identify requested instance types.
*
- * @note This class is not need to know during add-on development thats why
+ * @note This class is not necessary to know during add-on development hence | xbmc/addons/kodi-dev-kit/include/kodi/AddonBase.h | 26 | C/C++ | 0.5 | security | 175 | 51 | 51 | false | Fix typos found in various addons directories | 26,414 | xbmc/xbmc | 17,740 | C++ | ksooo | luzpaz |
//============================================================================
/// @ingroup CWindow
/// @brief Class destructor.
///
~CWindow() override
{
if (m_controlHandle)
m_interface->kodi_gui->window->destroy(m_interface->kodiBase, m_controlHandle);
}
//----------------------------------... | `@return True on success, false otherwise` | //============================================================================
/// @ingroup CWindow
/// @brief Class destructor.
///
~CWindow() override
{
if (m_controlHandle)
m_interface->kodi_gui->window->destroy(m_interface->kodiBase, m_controlHandle);
}
//----------------------------------... | @@ -164,7 +164,7 @@ class ATTR_DLL_LOCAL CWindow : public CAddonGUIControlBase
/// closed. The creation can be done before "Show" becomes called, but
/// not delete class after them.
///
- /// @return Return true if call and show is successed, if false was something
+ /// @return Return true if call and show... | xbmc/addons/kodi-dev-kit/include/kodi/gui/Window.h | 26 | C/C++ | 0.286 | suggestion | 42 | 51 | 51 | false | Fix typos found in various addons directories | 26,414 | xbmc/xbmc | 17,740 | C++ | ksooo | luzpaz |
//============================================================================
/// @ingroup cpp_kodi_gui_windows_window
/// @brief Closes this window.
///
/// Closes this window by activating the old window.
/// @note The window is not deleted with this method.
///
void Close() { m_interface->kodi_gui->... | `@return True on success, false otherwise` | /// @ingroup cpp_kodi_gui_windows_window
/// @brief Closes this window.
///
/// Closes this window by activating the old window.
/// @note The window is not deleted with this method.
///
void Close() { m_interface->kodi_gui->window->close(m_interface->kodiBase, m_controlHandle); }
//--------------------... | @@ -198,7 +198,7 @@ class ATTR_DLL_LOCAL CWindow : public CAddonGUIControlBase
/// @brief Gives the control with the supplied focus.
///
/// @param[in] controlId On skin defined id of control
- /// @return Return true if call and focus is successed, if false was something
+ /// @return Return true if call an... | xbmc/addons/kodi-dev-kit/include/kodi/gui/Window.h | 26 | C/C++ | 0.286 | suggestion | 42 | 51 | 51 | false | Fix typos found in various addons directories | 26,414 | xbmc/xbmc | 17,740 | C++ | ksooo | luzpaz |
/// @ingroup cpp_kodi_gui_windows_controls_CRendering
/// @brief Destructor.
///
~CRendering() override
{
m_interface->kodi_gui->control_rendering->destroy(m_interface->kodiBase, m_controlHandle);
}
//--------------------------------------------------------------------------
//=====================... | `@return True on success, false otherwise` | /// @ingroup cpp_kodi_gui_windows_controls_CRendering
/// @brief Destructor.
///
~CRendering() override
{
m_interface->kodi_gui->control_rendering->destroy(m_interface->kodiBase, m_controlHandle);
}
//--------------------------------------------------------------------------
//=====================... | @@ -93,7 +93,7 @@ class ATTR_DLL_LOCAL CRendering : public CAddonGUIControlBase
/// @param[in] h Height of control
/// @param[in] device The device to use. For OpenGL is empty on Direct X is
/// the needed device send.
- /// @return Add-on needs to return true if successed, otherwise false.
... | xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Rendering.h | 26 | C/C++ | 0.286 | suggestion | 42 | 51 | 51 | false | Fix typos found in various addons directories | 26,414 | xbmc/xbmc | 17,740 | C++ | ksooo | luzpaz |
echo -ne "\033]0;building FFmpeg $TRIPLET\007"
echo "-------------------------------------------------"
echo " building FFmpeg $TRIPLET"
echo "-------------------------------------------------"
./buildffmpeg.sh $MAKECLEAN
checkfiles lib/avcodec.lib lib/avformat.lib lib/avutil.lib lib/postproc.lib lib/swscale.lib lib/a... | guess this is a tab v spaces things, mind fixing it up to match whatever the rest of the doc is using. |
echo -ne "\033]0;building FFmpeg $TRIPLET\007"
echo "-------------------------------------------------"
echo " building FFmpeg $TRIPLET"
echo "-------------------------------------------------"
./buildffmpeg.sh $MAKECLEAN
checkfiles lib/avcodec.lib lib/avformat.lib lib/avutil.lib lib/postproc.lib lib/swscale.lib lib/a... | @@ -117,6 +121,8 @@ run_builds() {
profile_path=/local64/etc/profile.local
elif [[ $buildArm = "yes" ]]; then
profile_path=/local32/etc/profile.local
+ elif [[ $buildArm64 = "yes" ]]; then | tools/buildsteps/windows/make-mingwlibs.sh | 26 | Shell | 0.286 | suggestion | 102 | 51 | 51 | false | Build script updates to support Windows ARM64 | 26,438 | xbmc/xbmc | 17,740 | C++ | fuzzard | ddscentral |
FFMPEG_VERSION_FILE=/xbmc/tools/depends/target/ffmpeg/FFMPEG-VERSION
FFMPEG_BASE_OPTS="--disable-debug --disable-doc --enable-gpl --enable-w32threads"
FFMPEG_DEFAULT_OPTS=""
FFMPEG_TARGET_OS=mingw32
do_loaddeps $FFMPEG_VERSION_FILE
FFMPEGDESTDIR=$PREFIX
do_getFFmpegConfig() {
if [[ -f "$FFMPEG_CONFIG_FILE" ]]; then... | Leftover white space at end of line

| FFMPEG_VERSION_FILE=/xbmc/tools/depends/target/ffmpeg/FFMPEG-VERSION
FFMPEG_BASE_OPTS="--disable-debug --disable-doc --enable-gpl --enable-w32threads"
FFMPEG_DEFAULT_OPTS=""
FFMPEG_TARGET_OS=mingw32
do_loaddeps $FFMPEG_VERSION_FILE
FFMPEGDESTDIR=$PREFIX
do_getFFmpegConfig() {
if [[ -f "$FFMPEG_CONFIG_FILE" ]]; then... | @@ -27,6 +27,9 @@ do_getFFmpegConfig() {
elif [ "$ARCH" == "arm" ]; then
FFMPEG_TARGET_OS=mingw32
do_addOption "--cpu=armv7"
+ elif [ "$ARCH" == "arm64" ]; then
+ FFMPEG_TARGET_OS=mingw32
+ do_addOption "--cpu=armv8-a" | tools/buildsteps/windows/buildffmpeg.sh | 26 | Shell | 0.5 | suggestion | 130 | 51 | 51 | false | Build script updates to support Windows ARM64 | 26,438 | xbmc/xbmc | 17,740 | C++ | thexai | ddscentral |
case $1 in
--build32=* ) build32="${1#*=}"; shift ;;
--build64=* ) build64="${1#*=}"; shift ;;
--buildArm=* ) buildArm="${1#*=}"; shift ;;
--buildArm64=* ) buildArm64="${1#*=}"; shift ;;
--prompt=* ) PROMPTLEVEL="${1#*=}"; shift ;;
--mode=* ) BUILDMODE="${1#*=}"; shift ;;
--win10=* ) win10... | Leftover white space at end of line. | case $1 in
--build32=* ) build32="${1#*=}"; shift ;;
--build64=* ) build64="${1#*=}"; shift ;;
--buildArm=* ) buildArm="${1#*=}"; shift ;;
--buildArm64=* ) buildArm64="${1#*=}"; shift ;;
--prompt=* ) PROMPTLEVEL="${1#*=}"; shift ;;
--mode=* ) BUILDMODE="${1#*=}"; shift ;;
--win10=* ) win10... | @@ -33,6 +34,9 @@ elif [[ $build64 = "yes" ]]; then
elif [[ $buildArm = "yes" ]]; then
TRIPLET=arm
ARCH=arm
+elif [[ $buildArm64 = "yes" ]]; then
+ TRIPLET=arm64
+ ARCH=arm64 | tools/buildsteps/windows/make-mingwlibs.sh | 26 | Shell | 0.071 | suggestion | 36 | 51 | 51 | false | Build script updates to support Windows ARM64 | 26,438 | xbmc/xbmc | 17,740 | C++ | thexai | ddscentral |
{
currentSeason = episode.iSeason;
currentEpisode = episode.iEpisode;
episodeList.push_back(episode);
remainder = reg.GetMatch(3);
}
else
{
if (offset == 0)
{
... | should the log of new season be here? | (regexppos >= 0 && regexp2pos == -1))
{
GetEpisodeAndSeasonFromRegExp(reg, episode, defaultSeason);
if (currentSeason == episode.iSeason)
{
// Already added SxxEyy now loop (if needed) to SxxEzz
const int last{episode.iEpisode};
... | @@ -1332,32 +1332,78 @@ CVideoInfoScanner::~CVideoInfoScanner()
// check the remainder of the string for any further episodes.
if (!byDate && reg2.RegComp(m_advancedSettings->m_tvshowMultiPartEnumRegExp))
{
- int offset = 0;
+ int offset{0};
+ int currentSeason{episode.iSeason}... | xbmc/video/VideoInfoScanner.cpp | 26 | C++ | 0.286 | question | 37 | 51 | 51 | false | [VideoInfoScanner] Allow scraper to correctly process episodes in files named with the format SxxExx-Eyy and add further tests. | 26,439 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
// Already added first episode of invalid range so remove it
episodeList.pop_back();
remainder = reg.GetMatch(3);
}
else
remainder = remainder.substr(offset);
}
}
offset = 0;
... | wouldn't hurt to log some details to help future troubleshooting of failing user scans | ProcessEpisodeRange(next, last, episode, episodeList,
m_advancedSettings->m_tvshowMultiPartEnumRegExp);
currentEpisode = episode.iEpisode;
remainder = reg.GetMatch(3);
}
else
{
// Two possible ... | @@ -1332,32 +1332,78 @@ CVideoInfoScanner::~CVideoInfoScanner()
// check the remainder of the string for any further episodes.
if (!byDate && reg2.RegComp(m_advancedSettings->m_tvshowMultiPartEnumRegExp))
{
- int offset = 0;
+ int offset{0};
+ int currentSeason{episode.iSeason}... | xbmc/video/VideoInfoScanner.cpp | 26 | C++ | 0.357 | bug | 86 | 51 | 51 | false | [VideoInfoScanner] Allow scraper to correctly process episodes in files named with the format SxxExx-Eyy and add further tests. | 26,439 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
// we want "long circuit" OR below so that both offsets are evaluated
while (static_cast<int>((regexp2pos = reg2.RegFind(remainder.c_str() + offset)) > -1) |
static_cast<int>((regexppos = reg.RegFind(remainder.c_str() + offset)) > -1))
{
if ((regexppos <= regexp2pos && ... | comments in opposite order of the code. alternatively the comment pieces could go in the relevant code blocks. | if (byDate)
{
GetAirDateFromRegExp(reg, parent);
if (episode.cDate == parent.cDate)
episode.isFolder = true;
}
else
{
GetEpisodeAndSeasonFromRegExp(reg, parent, defaultSeason);
if (episode.iSeason == parent.iSeason && episode.iE... | @@ -1332,32 +1332,78 @@ CVideoInfoScanner::~CVideoInfoScanner()
// check the remainder of the string for any further episodes.
if (!byDate && reg2.RegComp(m_advancedSettings->m_tvshowMultiPartEnumRegExp))
{
- int offset = 0;
+ int offset{0};
+ int currentSeason{episode.iSeason}... | xbmc/video/VideoInfoScanner.cpp | 26 | C++ | 0.5 | suggestion | 110 | 51 | 51 | false | [VideoInfoScanner] Allow scraper to correctly process episodes in files named with the format SxxExx-Eyy and add further tests. | 26,439 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
currentEpisode = episode.iEpisode;
remainder = reg.GetMatch(3);
}
else
{
// Two possible scenarios here:
if (!remainder.starts_with("-"))
{
// (Sxx)Eyy has already been added and we now in a new ran... | copilot is wrong about the fix, but correct that there is a problem.
CLog::LogF(LOGDEBUG, .....) | {
if ((regexppos <= regexp2pos && regexppos != -1) || // season (or 'ep') match
(regexppos >= 0 && regexp2pos == -1))
{
GetEpisodeAndSeasonFromRegExp(reg, episode, defaultSeason);
if (currentSeason == episode.iSeason)
{
// Alrea... | @@ -1323,36 +1323,108 @@ CVideoInfoScanner::~CVideoInfoScanner()
// add what we found by now
episodeList.push_back(episode);
+ const bool disableEpisodeRanges{
+ CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_disableEpisodeRanges};
+
CRegExp reg2(true, CRegExp::aut... | xbmc/video/VideoInfoScanner.cpp | 26 | C++ | 0.429 | bug | 97 | 51 | 51 | false | [VideoInfoScanner] Allow scraper to correctly process episodes in files named with the format SxxExx-Eyy and add further tests. | 26,439 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
std::string strBasePath = item->GetBaseMoviePath(true);
URIUtils::RemoveSlashAtEnd(strBasePath);
strBasePath = URIUtils::GetFileName(strBasePath);
if (reg.RegFind(strBasePath.c_str()) > -1)
{
EPISODE parent;
if (byDate)
{
GetAirDateFromRegExp(reg, parent)... | Is there a reason to not use the m_advancedSettings member? | expression[i].regexp);
}
else if (byTitle)
{
if (!GetEpisodeTitleFromRegExp(reg, episode))
continue;
CLog::Log(LOGDEBUG, "VideoInfoScanner: Found title based match {} ({}) [{}]",
CURL::GetRedacted(episode.strPath), episode.strTitle, expres... | @@ -1323,36 +1323,108 @@ CVideoInfoScanner::~CVideoInfoScanner()
// add what we found by now
episodeList.push_back(episode);
+ const bool disableEpisodeRanges{
+ CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_disableEpisodeRanges}; | xbmc/video/VideoInfoScanner.cpp | 26 | C++ | 0.357 | question | 59 | 51 | 51 | false | [VideoInfoScanner] Allow scraper to correctly process episodes in files named with the format SxxExx-Eyy and add further tests. | 26,439 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.