mirror of
https://github.com/clsid2/mpc-hc
synced 2026-11-26 18:08:01 +08:00
Only use OpenSubtitles for automatic search if a login is set
This commit is contained in:
1 parent
163eea2e43
commit
caeca57d80
4 files changed
+27
-18
No files matched your search
@@ -348,6 +348,11 @@ bool OpenSubtitles2::NeedLogin()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool OpenSubtitles2::UseForAutoDownload()
|
||||
{
|
||||
return !UserName().empty();
|
||||
}
|
||||
|
||||
SRESULT OpenSubtitles2::Login(const std::string& sUserName, const std::string& sPassword)
|
||||
{
|
||||
SRESULT result = SR_FAILED;
|
||||
|
||||
@@ -70,6 +70,7 @@ bool NeedLogin() override;
|
||||
SRESULT Login(const std::string& sUserName, const std::string& sPassword) override;
|
||||
SRESULT LogOut() override;
|
||||
SRESULT Hash(SubtitlesInfo& pFileInfo) override;
|
||||
bool UseForAutoDownload() override;
|
||||
|
||||
struct Response {
|
||||
DWORD code = 0;
|
||||
|
||||
@@ -712,8 +712,10 @@ void SubtitlesTask::ThreadProc()
|
||||
if (do_search) {
|
||||
for (const auto& iter : m_pMainFrame->m_pSubtitlesProviders->Providers()) {
|
||||
if (iter->Enabled(SPF_SEARCH) && !IsThreadAborting()) {
|
||||
CAutoLock tlock(&m_csThreadLock);
|
||||
InsertThread(DEBUG_NEW SubtitlesThread(this, pFileInfo, iter));
|
||||
if (!(m_nType & STT_DOWNLOAD) || iter->UseForAutoDownload()) {
|
||||
CAutoLock tlock(&m_csThreadLock);
|
||||
InsertThread(DEBUG_NEW SubtitlesThread(this, pFileInfo, iter));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -737,26 +739,26 @@ void SubtitlesTask::ThreadProc()
|
||||
Sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Wait here until all threads have finished
|
||||
while (!m_pThreads.empty()) {
|
||||
Sleep(20);
|
||||
}
|
||||
// Wait until all threads have finished
|
||||
while (!m_pThreads.empty()) {
|
||||
Sleep(20);
|
||||
}
|
||||
|
||||
if (m_nType & STT_SEARCH) {
|
||||
BOOL bShowDialog = !m_AutoDownload.empty() || m_bAutoDownload;
|
||||
for (const auto& iter : m_AutoDownload) {
|
||||
if (iter.second) {
|
||||
bShowDialog = FALSE;
|
||||
break;
|
||||
if (m_nType & STT_SEARCH) {
|
||||
BOOL bShowDialog = !m_AutoDownload.empty() || m_bAutoDownload;
|
||||
for (const auto& iter : m_AutoDownload) {
|
||||
if (iter.second) {
|
||||
bShowDialog = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool isAbort = IsThreadAborting();
|
||||
if (!isAbort || !AfxGetMyApp()->m_fClosingState) {
|
||||
m_pMainFrame->m_wndSubtitlesDownloadDialog.DoFinished(isAbort, bShowDialog);
|
||||
}
|
||||
} else if (m_nType & STT_DOWNLOAD) {
|
||||
}
|
||||
bool isAbort = IsThreadAborting();
|
||||
if (!isAbort || !AfxGetMyApp()->m_fClosingState) {
|
||||
m_pMainFrame->m_wndSubtitlesDownloadDialog.DoFinished(isAbort, bShowDialog);
|
||||
}
|
||||
} else if (m_nType & STT_DOWNLOAD) {
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -334,6 +334,7 @@ public: // overridden
|
||||
VersionInfo::GetMinorNumber(),
|
||||
VersionInfo::GetPatchNumber());
|
||||
}
|
||||
virtual bool UseForAutoDownload() { return true; }
|
||||
|
||||
bool LoginInternal();
|
||||
void OpenUrl() const;
|
||||
|
||||
Reference in new issue
Block a user