Skip to content

Commit

Permalink
Merge pull request #826 from phunkyfish/conn-mgr-special-paths
Browse files Browse the repository at this point in the history
Fix supporting of local paths in Connection Manager
  • Loading branch information
phunkyfish committed Jan 5, 2024
2 parents cc885d2 + 4b8bfa7 commit a063bdd
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pvr.iptvsimple/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.iptvsimple"
version="21.7.0"
version="21.7.1"
name="IPTV Simple Client"
provider-name="nightik and Ross Nicholson">
<requires>@ADDON_DEPENDS@
Expand Down
3 changes: 3 additions & 0 deletions pvr.iptvsimple/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v21.7.1
- Fix supporting of local paths in Connection Manager

v21.7.0
- Add connection manager support to wait for a valid M3U file before starting the add-on instance
- The minimum refresh interval for the M3U should be 1 minutes and not zero, as that would be infinite refresh
Expand Down
4 changes: 3 additions & 1 deletion src/iptvsimple/ConnectionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ void ConnectionManager::Process()
}

const std::string url = m_settings->GetM3ULocation();
int tcpTimeout = m_settings->GetConnectioncCheckTimeoutSecs();
bool isLocalPath = m_settings->GetM3UPathType() == PathType::LOCAL_PATH;

/* URL is set */
if (url.empty())
Expand All @@ -151,7 +153,7 @@ void ConnectionManager::Process()
}

/* Connect */
if ((firstRun || !m_onStartupOnly) && !WebUtils::Check(url, m_settings->GetConnectioncCheckTimeoutSecs()))
if ((firstRun || !m_onStartupOnly) && !WebUtils::Check(url, tcpTimeout, isLocalPath))
{
/* Unable to connect */
if (retryAttempt == 0)
Expand Down
1 change: 0 additions & 1 deletion src/iptvsimple/ConnectionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ namespace iptvsimple
PVR_CONNECTION_STATE m_state;

bool m_onStartupOnly = true;
bool m_notifyStateChangeToUser = false;

std::shared_ptr<iptvsimple::InstanceSettings> m_settings;
};
Expand Down
8 changes: 7 additions & 1 deletion src/iptvsimple/utilities/WebUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "WebUtils.h"

#include "FileUtils.h"
#include "Logger.h"

#include <cctype>
Expand Down Expand Up @@ -130,8 +131,13 @@ std::string WebUtils::RedactUrl(const std::string& url)
return redactedUrl;
}

bool WebUtils::Check(const std::string& strURL, int connectionTimeoutSecs)
bool WebUtils::Check(const std::string& strURL, int connectionTimeoutSecs, bool isLocalPath)
{
// For local paths we only need to check existence of the file
if (isLocalPath && FileUtils::FileExists(strURL))
return true;

//Otherwise it's remote
kodi::vfs::CFile fileHandle;
if (!fileHandle.CURLCreate(strURL))
{
Expand Down
2 changes: 1 addition & 1 deletion src/iptvsimple/utilities/WebUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace iptvsimple
static std::string ReadFileContentsStartOnly(const std::string& url, int* httpCode);
static bool IsHttpUrl(const std::string& url);
static std::string RedactUrl(const std::string& url);
static bool Check(const std::string& url, int connectionTimeoutSecs);
static bool Check(const std::string& url, int connectionTimeoutSecs, bool isLocalPath = false);
};
} // namespace utilities
} // namespace iptvsimple

0 comments on commit a063bdd

Please sign in to comment.