Example #1
0
			i -= 1
			pos += pktsz
		else:
			i = 5
			pos = d.find('G', pos + 1)

	if i or pos == -1:
		return False

	return True

def detectmpegts(path, fobj):
	if not findtsstream(fobj):
		return None, None

	f = mpegts.TSPStream(_LimitedFile(path, size= 2*1024*1024))
	tvct = mpegts.GetTVCT(f)

	if len(tvct['channels']) == 1:
		#return None, None
		# We might reenable this once we have pid filtering working
		# fast enough.
		return MPEGTS, { 'path': path, 'tvct': tvct['channels'][0] }
	elif len(tvct['channels']) > 1:
		#log.msg('MultiMPEGTS: path: %s' % path)
		return MultiMPEGTS, { 'path': path }

	return None, None

registerklassfun(detectmpegts)
Example #2
0
			# new object
			if isinstance(hier[i], dict):
				# must be a dir
				self.pathObjmap[i] = self.cd.addItem(self.id,
				    ZipChildDir, i, zf=self.zip, zo=self,
				    name=i, hier=hier[i], sep=cursep)
			else:
				klass, mt = FileDIDL.buildClassMT(ZipFile, i)
				if klass is None:
					continue
				self.pathObjmap[i] = self.cd.addItem(self.id,
				    klass, i, zf = self.zip, zo = self,
				    name = i, mimetype = mt)
			doupdate = True

		# sort our children
		self.sort(lambda x, y: cmp(x.title, y.title))

		if doupdate:
			StorageFolder.doUpdate(self)

def detectzipfile(path, fobj):
	try:
		canHandle(path)
	except:
		return None, None

	return ZipObject, { 'path': path }

registerklassfun(detectzipfile)
Example #3
0
		doupdate = False
		for i in self.pathObjmap.keys():
			if i not in nl:
				# delete
				doupdate = True
				self.cd.delItem(self.pathObjmap[i])
				del self.pathObjmap[i]

		for i in nl:
			if i in self.pathObjmap:
				continue
			doupdate = True
			self.pathObjmap[i] = self.cd.addItem(self.id,
				ShoutGenre, i, genre = i)

		self.genre_list = nl

		# sort our children
		self.sort(lambda x, y: cmp(x.title, y.title))
		if doupdate:
			Container.doUpdate(self)

def detectshoutcastfile(path, fobj):
	path = os.path.basename(path)
	if path == 'SHOUTcast Radio':
		return ShoutCast, { }
	return None, None

registerklassfun(detectshoutcastfile)
Example #4
0
				del self.pathObjmap[i]

		# This data is referenced when adding new shows
		self.shows = nl
		for i in nl:
			if i in self.pathObjmap:
				continue
			doupdate = True
			try:
				self.pathObjmap[i] = self.cd.addItem(self.id,
					PYVRShows, i, show=i, pyvr=self)
			except:
				import traceback
				traceback.print_exc(file=log.logfile)
				raise

		self.newobjs = None

		# sort our children
		self.sort(lambda x, y: cmp(x.title, y.title))
		if doupdate:
			Container.doUpdate(self)

def detectpyvrfile(path, fobj):
	bn = os.path.basename(path)
	if bn == 'PYVR':
		return PYVR, { 'url': fobj.readline().strip() }
	return None, None

registerklassfun(detectpyvrfile)
Example #5
0
		for i in origchildren:
			if i in self.pathObjmap:
				continue

			# new object
			self.pathObjmap[i] = self.cd.addItem(self.id, DVDTitle,
			    i, dvdtitle = self.dvd[toindex[i]], dvddisc = self)
			doupdate = True

		if doupdate:
			StorageFolder.doUpdate(self)

def detectdvd(path, fobj):
	if os.path.isdir(path):
		# Make sure we there is only a VIDEO_TS in there, even
		# if there is a VIDEO_TS w/ other files, we will open
		# the VIDEO_TS as a DVD (if it is one)
		ld = os.listdir(path)
		if ld == ['VIDEO_TS' ]:
			pass
		elif not filter(lambda x: x[:4] != 'VTS_' and
		    x[:9] != 'VIDEO_TS.', ld):
			pass
		else:
			return None, None

	d = DVD(path)
	return DVDDisc, { 'path': path }

registerklassfun(detectdvd)