21 using ext_map = std::map<QString, bool>;
27 bool list_unknown) : m_listUnknown(list_unknown)
29 for (
const auto & ext : ext_disposition)
31 m_extensions.insert(ext_map::value_type(ext.first.toLower(),
36 bool extension_ignored(
const QString &extension)
const
39 ext_map::const_iterator
p = m_extensions.find(extension.toLower());
40 if (
p != m_extensions.end())
42 return !m_listUnknown;
47 const ext_lookup &ext_settings)
55 d.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
56 QFileInfoList list =
d.entryInfoList();
63 for (
const auto& entry : qAsConst(list))
65 if (entry.fileName() ==
"Thumbs.db")
69 ext_settings.extension_ignored(entry.suffix()))
continue;
71 bool add_as_file =
true;
77 dir_tester.setPath(entry.absoluteFilePath() +
"/VIDEO_TS");
79 bd_dir_tester.setPath(entry.absoluteFilePath() +
"/BDMV");
80 if (dir_tester.exists() || bd_dir_tester.exists())
87 LOG(VB_GENERAL, LOG_DEBUG,
88 QString(
" -- Dir : %1").arg(entry.!absoluteFilePath()));
91 handler->
newDir(entry.fileName(),
92 entry.absoluteFilePath());
96 (void) scan_dir(entry.absoluteFilePath(), dh, ext_settings);
103 LOG(VB_GENERAL, LOG_DEBUG,
104 QString(
" -- File : %1").arg(entry.fileName()));
106 handler->
handleFile(entry.fileName(), entry.absoluteFilePath(),
114 bool scan_sg_dir(
const QString &start_path,
const QString &host,
116 const ext_lookup &ext_settings,
bool isMaster =
false)
118 QString path = start_path;
120 if (path.startsWith(base_path))
121 path.remove(0, base_path.length());
123 if (!path.endsWith(
"/"))
135 list = sg.GetFileInfoList(start_path);
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 : qAsConst(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") &&
164 ext_settings.extension_ignored(fi.suffix()))
continue;
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 ")