def __init__(self, opts, name, root, vidlist, harvesters): self.name = name self.title = name self.opts = opts.copy() self.count = 0 self.root = root self.videoDir = VideoDir(opts, "", "", root, name) tree = myWalk(root) sharedirs = {"": self.videoDir} shareopts = {"": self.opts} for path, dirs, files in tree: rpath = path[len(root) :] if rpath.startswith(os.path.sep): rpath = rpath[1:] if rpath not in sharedirs: continue vl = sharedirs[rpath] lopts = shareopts[rpath] Config.addLocalOpts(lopts, root, rpath) vl.setOpts(lopts) for name in dirs: if name.startswith("."): continue meta = metadata.from_text( os.path.join(path, name, "folder"), lopts["metamergefiles"], lopts["metamergelines"], lopts["metamergeparent"], ) d = VideoDir(lopts, name, rpath, path, self.name) d.setMeta(meta) vl.addDir(d) sharedirs[os.path.join(rpath, name)] = d shareopts[os.path.join(rpath, name)] = lopts.copy() for name in files: if name.startswith("."): continue if os.path.splitext(name)[1].lower() in lopts["goodexts"]: fid = fileId(os.path.join(path, name)) if fid != None: vf = vidlist.findVideo(fid) else: vf = None if vf == None: vf = VideoFile(lopts, path, name, fid) vidlist.addVideo(vf) meta = metadata.from_text( os.path.join(path, name), lopts["metamergefiles"], lopts["metamergelines"], lopts["metamergeparent"], ) if not "title" in meta: meta = metadata.basic(os.path.join(path, name)) vf.setMeta(meta) vl.addVideo(vf) self.count += 1 for h in harvesters: h.harvest(vf) else: vl.addVideo(vf, path=path, fn=name) self.count += 1 vl.sort()
def __init__(self, opts, name, root, vidlist, harvesters): self.name = name self.title = name self.opts = opts.copy() self.count = 0 self.root = root self.videoDir = VideoDir(opts, "", "", root, name) tree = myWalk(root) sharedirs = {"": self.videoDir} shareopts = {"": self.opts} for path, dirs, files in tree: rpath = path[len(root):] if rpath.startswith(os.path.sep): rpath = rpath[1:] if rpath not in sharedirs: continue vl = sharedirs[rpath] lopts = shareopts[rpath] Config.addLocalOpts(lopts, root, rpath) vl.setOpts(lopts) for name in dirs: if name.startswith("."): continue meta = metadata.from_text(os.path.join(path, name, "folder"), lopts['metamergefiles'], lopts['metamergelines']) d = VideoDir(lopts, name, rpath, path, self.name) d.setMeta(meta) vl.addDir(d) sharedirs[os.path.join(rpath, name)] = d shareopts[os.path.join(rpath, name)] = lopts.copy() for name in files: if name.startswith("."): continue if os.path.splitext(name)[1].lower() in lopts['goodexts']: fid = fileId(os.path.join(path, name)) if fid != None: vf = vidlist.findVideo(fid) else: vf = None if vf == None: vf = VideoFile(lopts, path, name, fid) vidlist.addVideo(vf) meta = metadata.from_text(os.path.join(path, name), lopts['metamergefiles'], lopts['metamergelines']) if not 'title' in meta: meta = metadata.basic(os.path.join(path, name)) vf.setMeta(meta) vl.addVideo(vf) self.count += 1 for h in harvesters: h.harvest(vf) else: vl.addVideo(vf, path=path, fn=name) self.count += 1 vl.sort()
def __init__(self, opts, name, root, vidlist, harvesters): self.name = name self.title = name self.opts = opts.copy() self.count = 0 self.root = root self.videoDir = VideoDir(self.opts, "", "", root, name) shareopts = {"": self.opts} sharedirs = {"": self.videoDir} tree = os.walk(root) for path, dirs, files in tree: rpath = path[len(root):] if rpath.startswith(os.path.sep): rpath = rpath[1:] if rpath not in sharedirs: continue vdir = sharedirs[rpath] lopts = shareopts[rpath] Config.addLocalOpts(lopts, root, rpath) vdir.setOpts(lopts) if self.isDvdDir(path): p, deftitle = os.path.split(path) meta, titles = self.loadDvdMeta(path, lopts, "default", deftitle, False) fid = fileId(os.path.join(path, "default.txt")) for (title, fn, tn) in titles: if fid != None: vf = vidlist.findVideo((fid, tn)) else: vf = None if vf == None: vf = VideoFile(lopts, path, fn, (fid, tn)) vidlist.addVideo(vf) meta, t = self.loadDvdMeta(path, lopts, fn, title, True) meta['title'] = title meta['titleNumber'] = tn vf.setMeta(meta) vdir.addVideo(vf) self.count += 1 for h in harvesters: h.harvest(vf) else: vdir.addVideo(vf, path=path, fn=fn) self.count += 1 else: for dn in dirs: if dn.startswith("."): continue cdir = os.path.join(path, dn) if self.isDvdDir(cdir): meta, tnames = self.loadDvdMeta( cdir, lopts, "default", dn, False) d = DVDDir(lopts, dn, rpath, path, self.name) else: meta = metadata.from_text( os.path.join(path, dn, "folder"), lopts['metamergefiles'], lopts['metamergelines']) d = VideoDir(lopts, dn, rpath, path, self.name) d.setMeta(meta) vdir.addDir(d) sharedirs[os.path.join(rpath, dn)] = d shareopts[os.path.join(rpath, dn)] = lopts.copy() vdir.sort()
def __init__(self, opts, name, root, vidlist, harvesters): self.name = name self.title = name self.opts = opts.copy() self.count = 0 self.root = root self.videoDir = VideoDir(self.opts, "", "", root, name) shareopts = {"": self.opts} sharedirs = {"": self.videoDir} tree = os.walk(root) for path, dirs, files in tree: rpath = path[len(root):] if rpath.startswith(os.path.sep): rpath = rpath[1:] if rpath not in sharedirs: continue vdir = sharedirs[rpath] lopts = shareopts[rpath] Config.addLocalOpts(lopts, root, rpath) vdir.setOpts(lopts) if self.isDvdDir(path): p, deftitle = os.path.split(path) meta, titles = self.loadDvdMeta(path, lopts, "default", deftitle, False) fid = fileId(os.path.join(path, "default.txt")) for (title, fn, tn) in titles: if fid != None: vf = vidlist.findVideo((fid, tn)) else: vf = None if vf == None: vf = VideoFile(lopts, path, fn, (fid, tn)) vidlist.addVideo(vf) meta, t = self.loadDvdMeta(path, lopts, fn, title, True) meta['title'] = title meta['titleNumber'] = tn vf.setMeta(meta) vdir.addVideo(vf) self.count += 1 for h in harvesters: h.harvest(vf) else: vdir.addVideo(vf, path=path, fn=fn) self.count += 1 else: for dn in dirs: if dn.startswith("."): continue cdir = os.path.join(path, dn) if self.isDvdDir(cdir): meta, tnames = self.loadDvdMeta(cdir, lopts, "default", dn, False) d = DVDDir(lopts, dn, rpath, path, self.name) else: meta = metadata.from_text( os.path.join(path, dn, "folder"), lopts['metamergefiles'], lopts['metamergelines']) d = VideoDir(lopts, dn, rpath, path, self.name) d.setMeta(meta) vdir.addDir(d) sharedirs[os.path.join(rpath, dn)] = d shareopts[os.path.join(rpath, dn)] = lopts.copy() vdir.sort()