Skip to content

Commit

Permalink
*Extended UrlToData for secure HTTPS connections
Browse files Browse the repository at this point in the history
*fixed covers pictures not working
*default to directory name if no file found inside
  • Loading branch information
ryanjay0 committed Sep 18, 2016
1 parent 9f9a457 commit de3f7cd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 14 deletions.
10 changes: 9 additions & 1 deletion MovieExplorer/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,11 +627,19 @@ void CDatabase::SyncAndUpdate()
pMov->fileSize = FileSize(strFilePath + _T("\\") + strFileName);
pMov->fileTime = fi.lastWriteTime;
}
else
{

//If we can't find a filename just use the directory

pMov->strFileName = fi.strName;
pMov->fileSize = fi.size;
pMov->fileTime = fi.lastWriteTime;
}

}
else
{

pMov->strFileName = fi.strName;
pMov->fileSize = fi.size;
pMov->fileTime = fi.lastWriteTime;
Expand Down
14 changes: 6 additions & 8 deletions MovieExplorer/ScrapeIMDb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,22 +243,20 @@ DWORD ScrapeIMDb(DBINFO *pInfo)

if (_tcsicmp(GETPREFSTR(_T("InfoService"), _T("Poster")), _T("imdb.com")) == 0)
{
if (GetFirstMatch(str, _T("title=\"[^\"]*?Poster\"[^>]*?(http://ia\\.media-imdb\\.com/images/M/[^\"]+?_V1\\.?_[^\"]*?)\\.([^\"]+?)\""),
&strTemp, &strTemp2, NULL))
if (GetFirstMatch(str, _T("title=\"[^\"]*?Poster\"[^\"]*?\"(https://[^\"]+?)\""),
&strTemp, NULL))
{
strTemp = strTemp + _T(".") + strTemp2; // take the server's default cropping and resizing
URLToData(strTemp, pInfo->posterData);
URLToData(strTemp, pInfo->posterData); // take the server's default cropping and resizing
}
else
{
//didn't find a poster, so if it's a tv show check original show page also
if (pInfo->bType == DB_TYPE_TV && !strOriginal.IsEmpty())
{
if (GetFirstMatch(strOriginal, _T("title=\"[^\"]*?Poster\"[^>]*?(http://ia\\.media-imdb\\.com/images/M/[^\"]+?_V1\\.?_[^\"]*?)\\.([^\"]+?)\""),
&strTemp, &strTemp2, NULL))
if (GetFirstMatch(strOriginal, _T("title=\"[^\"]*?Poster\"[^\"]*?\"(https://[^\"]+?)\""),
&strTemp, NULL))
{
strTemp = strTemp + _T(".") + strTemp2; // take the server's default cropping and resizing
URLToData(strTemp, pInfo->posterData);
URLToData(strTemp, pInfo->posterData); // take the server's default cropping and resizing
}
}
}
Expand Down
31 changes: 26 additions & 5 deletions RClasses/convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,33 @@ inline bool URLToData(RString strURL, RArray<BYTE>& data, bool& bUTF8)
data.SetSize(0);
bUTF8 = false;

// Extract server and object name
// Https or Http

if (strURL.GetLength() < 8)
return false;

if (strURL.GetLength() < 7 || !strURL.Left(7).Equals(_T("http://")))
bool bNormal = strURL.Left(7).Equals(_T("http://"));
bool bSecure = strURL.Left(8).Equals(_T("https://"));
if (!bSecure && !bNormal)
return false;

strURL.Replace(_T("http://"), _T(""));
// Extract server and object name

INTERNET_PORT nServerPort;
DWORD dwFlags = 0;

if (bNormal)
{
strURL.Replace(_T("http://"), _T(""));
nServerPort = INTERNET_DEFAULT_HTTP_PORT;
}
else if (bSecure)
{
strURL.Replace(_T("https://"), _T(""));
nServerPort = INTERNET_DEFAULT_HTTPS_PORT;
dwFlags = WINHTTP_FLAG_SECURE;
}

if (strURL.Find(_T('/')) == -1)
strURL += _T("/");

Expand All @@ -299,12 +320,12 @@ inline bool URLToData(RString strURL, RArray<BYTE>& data, bool& bUTF8)
if (!hSession)
return false;

HINTERNET hConnect = WinHttpConnect(hSession, strServerName, INTERNET_DEFAULT_HTTP_PORT, 0);
HINTERNET hConnect = WinHttpConnect(hSession, strServerName, nServerPort, 0);
if (!hConnect)
return false;

HINTERNET hRequest = WinHttpOpenRequest(hConnect, L"GET", strObjectName, NULL,
WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, 0);
WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, dwFlags);
if (!hRequest)
return false;

Expand Down

0 comments on commit de3f7cd

Please sign in to comment.