25 bool list_unknown) : m_listUnknown(list_unknown)
27 for (
const auto & ext : ext_disposition)
29 m_extensions.insert(ext_map::value_type(ext.first.toLower(),
37 ext_map::const_iterator
p = m_extensions.find(extension.toLower());
38 if (
p != m_extensions.end())
40 return !m_listUnknown;
53 d.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
54 QFileInfoList list =
d.entryInfoList();
61 for (
const auto& entry : std::as_const(list))
63 if (entry.fileName() ==
"Thumbs.db")
69 bool add_as_file =
true;
75 dir_tester.setPath(entry.absoluteFilePath() +
"/VIDEO_TS");
77 bd_dir_tester.setPath(entry.absoluteFilePath() +
"/BDMV");
78 if (dir_tester.exists() || bd_dir_tester.exists())
85 LOG(VB_GENERAL, LOG_DEBUG,
86 QString(
" -- Dir : %1").arg(entry.!absoluteFilePath()));
89 handler->
newDir(entry.fileName(),
90 entry.absoluteFilePath());
94 (void)
scan_dir(entry.absoluteFilePath(), dh, ext_settings);
101 LOG(VB_GENERAL, LOG_DEBUG,
102 QString(
" -- File : %1").arg(entry.fileName()));
104 handler->
handleFile(entry.fileName(), entry.absoluteFilePath(),
114 const ext_lookup &ext_settings,
bool isMaster =
false)
116 QString path = start_path;
118 if (path.startsWith(base_path))
119 path.remove(0, base_path.length());
121 if (!path.endsWith(
"/"))
141 if (!ok || (!list.isEmpty() && list.at(0).startsWith(
"SLAVE UNREACHABLE")))
143 LOG(VB_GENERAL, LOG_INFO,
144 QString(
"Backend : %1 : Is currently Unreachable. Skipping "
145 "this one.") .arg(host));
149 if (list.isEmpty() || (list.at(0) ==
"EMPTY LIST"))
152 for (
const auto& entry : std::as_const(list))
154 QStringList fInfo = entry.split(
"::");
155 const QString&
type = fInfo.at(0);
156 QString fileName = fInfo.at(1);
161 QFileInfo fi(fileName);
163 if ((
type !=
"dir") &&
167 !fileName.endsWith(
"VIDEO_TS") &&
168 !fileName.endsWith(
"BDMV"))
171 LOG(VB_GENERAL, LOG_DEBUG,
172 QString(
" -- Dir : %1").arg(fileName));
182 (void)
scan_sg_dir(start_path +
"/" + fileName, host, base_path,
183 dh, ext_settings, isMaster);
190 if (fileName.endsWith(
"VIDEO_TS") || fileName.endsWith(
"BDMV"))
192 if (path.startsWith(
"/"))
193 path = path.right(path.length() - 1);
194 if (path.endsWith(
"/"))
195 path = path.left(path.length() - 1);
196 QStringList upDirs = path.split(
"/");
197 if (upDirs.count() > 1)
198 fileName = upDirs.takeLast();
206 suffix = fi.suffix();
207 URL = QString(
"%1/%2").arg(path, fileName);
210 URL.replace(
"//",
"/");
212 if (URL.startsWith(
"/"))
213 URL = URL.right(URL.length() - 1);
215 LOG(VB_GENERAL, LOG_GENERAL,
216 QString(
" -- File Filename: %1 URL: %2 Suffix: %3 Host: %4")
217 .arg(fileName).arg(URL).arg(suffix).arg(QString(host)));
219 handler->
handleFile(fileName, URL, fi.suffix(), QString(host));
229 bool list_unknown_extensions)
231 ext_lookup extlookup(ext_disposition, list_unknown_extensions);
233 bool pathScanned =
true;
235 if (!start_path.startsWith(
"myth://"))
237 LOG(VB_GENERAL, LOG_INFO,
238 QString(
"MythVideo::ScanVideoDirectory Scanning (%1)")
241 if (!
scan_dir(start_path, handler, extlookup))
243 LOG(VB_GENERAL, LOG_ERR,
244 QString(
"MythVideo::ScanVideoDirectory failed to scan %1")
251 LOG(VB_GENERAL, LOG_INFO,
252 QString(
"MythVideo::ScanVideoDirectory Scanning Group (%1)")
254 QUrl sgurl = start_path;
255 QString host = sgurl.host();
256 QString path = sgurl.path();
258 if (!
scan_sg_dir(path, host, path, handler, extlookup,
262 LOG(VB_GENERAL, LOG_ERR,
263 QString(
"MythVideo::ScanVideoDirectory failed to scan %1 ")
virtual void handleFile(const QString &file_name, const QString &fq_file_name, const QString &extension, const QString &host)=0
virtual DirectoryHandler * newDir(const QString &dir_name, const QString &fq_dir_name)=0
std::vector< std::pair< QString, bool > > ext_ignore_list
QString GetHostName(void)
bool IsMasterHost(void)
is this the same host as the master
static bool remoteGetFileList(const QString &host, const QString &path, QStringList *list, QString sgroup, bool fileNamesOnly=false)
QStringList GetFileInfoList(const QString &Path)
std::map< QString, bool > ext_map
bool extension_ignored(const QString &extension) const
ext_lookup(const FileAssociations::ext_ignore_list &ext_disposition, bool list_unknown)
bool ScanVideoDirectory(const QString &start_path, DirectoryHandler *handler, const FileAssociations::ext_ignore_list &ext_disposition, bool list_unknown_extensions)
static const iso6937table * d
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
bool scan_sg_dir(const QString &start_path, const QString &host, const QString &base_path, DirectoryHandler *handler, const ext_lookup &ext_settings, bool isMaster=false)
bool scan_dir(const QString &start_path, DirectoryHandler *handler, const ext_lookup &ext_settings)