Repository URL to install this package:
#!/usr/bin/python
# coding=utf-8
#
# Copyright (C) 2018-2025 by dream-alpha
#
# In case of reuse of this source code please do not remove this copyright.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# For more information on the GNU General Public License see:
# <http://www.gnu.org/licenses/>.
# pylint: disable=no-member
import os
from Plugins.SystemPlugins.MountCockpit.MountCockpit import MountCockpit
from .Debug import logger
class Test():
def __init__(self, _session):
self.bookmarks = MountCockpit.getInstance().getMountedBookmarks("MVC")
self.exts = [".ts", ".mp4"]
self.ignore_files = [".sort", ".metalist"]
def listDir(self, adir):
alist = []
try:
for afile in os.listdir(adir):
if os.path.isfile(os.path.join(adir, afile)) and os.path.splitext(afile)[1] not in self.exts and os.path.basename(afile) not in self.ignore_files:
alist.append(os.path.join(adir, afile))
except OSError as e:
print("failed: e: %s" % e)
return alist
def start(self, index, callback):
logger.info("...")
success = True
alist = []
for bookmark in self.bookmarks:
alist += self.listDir(bookmark)
for afile in alist:
logger.debug("afile: %s", afile)
bfile, ext = os.path.splitext(afile)
logger.debug("bfile: %s, ext: %s", bfile, ext)
if os.path.isdir(bfile):
logger.debug("file is a dir, which is probably ok")
else:
cfile, ext = os.path.splitext(bfile)
if ext != ".ts":
for ext in self.exts:
logger.debug("cfile + ext: %s", cfile + ext)
if os.path.isfile(cfile + ext):
break
else:
logger.error("no video file for: %s", afile)
success = False
callback(index, success)