def __init__(self, title,season,number,oneclick):
     Search.__init__(self)
     self.title = title
     self.season = int(season)
     self.number = int(number)
     self.oneclick = oneclick
     self.mediatype = 'Show'
     query = '''{0} S{1:0>2}E{2:0>2}'''.format(self.title, self.season, self.number)
     self.dirs = furklib.searchFurk(query)
 def __init__(self, title, season, number, oneclick):
     Search.__init__(self)
     self.title = title
     self.season = int(season)
     self.number = int(number)
     self.oneclick = oneclick
     self.mediatype = 'Show'
     query = '''{0} S{1:0>2}E{2:0>2}'''.format(self.title, self.season,
                                               self.number)
     self.dirs = furklib.searchFurk(query)
    def deepsearch(self):
        dir_names = []
        dir_ids = []
        season_episode = "s%.2de%.2d" % (self.season, self.number)
        season_episode2 = "%d%.2d" % (self.season, self.number)

        tv_show_season = "%s season" % self.title
        tv_show_episode = "%s %s" % (self.title, season_episode)

        dirs2 = []
        dirs2.extend(furklib.myFiles(self.title))
        try:
            dirs2.extend(furklib.searchFurk(tv_show_episode))
        except:
            pass
        try:
            dirs2.extend(furklib.searchFurk(tv_show_season))
        except:
            pass
        try:
            dirs2.extend(furklib.searchFurk(self.title))
        except:
            pass
        for d in dirs2:
            if self.valids>0:
                continue
            if d['is_ready']=='0':
                continue
            if not (d['name'].lower().startswith(self.title.lower())):
                continue
            dir_names.append(d['name'])
            dir_ids.append(d['info_hash'])


        if len(dir_names)>0:
            idx = 0
            for dirname in dir_names:
                id = dir_ids[idx]
                idx = idx + 1
                self.filebyfile(id,dirname)
        else:
            pass
def SearchFromMenu(query):
	dirs = furklib.searchFurk(query)
	for dir in dirs:
		if dir['is_ready']=='0':
			continue
		id = dir['info_hash']
		dirname = dir['name']
		url = sys.argv[0]+'?action=listFiles&id='+id
		common.createListItem(dirname, True, url)
	common.endofDir()
	return
def SearchFromMenu(query):
    dirs = furklib.searchFurk(query)
    for dir in dirs:
        if dir['is_ready'] == '0':
            continue
        id = dir['info_hash']
        dirname = dir['name']
        url = sys.argv[0] + '?action=listFiles&id=' + id
        common.createListItem(dirname, True, url)
    common.endofDir()
    return
    def deepsearch(self):
        dir_names = []
        dir_ids = []
        season_episode = "s%.2de%.2d" % (self.season, self.number)
        season_episode2 = "%d%.2d" % (self.season, self.number)

        tv_show_season = "%s season" % self.title
        tv_show_episode = "%s %s" % (self.title, season_episode)

        dirs2 = []
        dirs2.extend(furklib.myFiles(self.title))
        try:
            dirs2.extend(furklib.searchFurk(tv_show_episode))
        except:
            pass
        try:
            dirs2.extend(furklib.searchFurk(tv_show_season))
        except:
            pass
        try:
            dirs2.extend(furklib.searchFurk(self.title))
        except:
            pass
        for d in dirs2:
            if self.valids > 0:
                continue
            if d['is_ready'] == '0':
                continue
            if not (d['name'].lower().startswith(self.title.lower())):
                continue
            dir_names.append(d['name'])
            dir_ids.append(d['info_hash'])

        if len(dir_names) > 0:
            idx = 0
            for dirname in dir_names:
                id = dir_ids[idx]
                idx = idx + 1
                self.filebyfile(id, dirname)
        else:
            pass
    def __init__(self, title,year,oneclick):
        Search.__init__(self)
        self.mediatype = 'Movie'
        self.title = title.encode("utf-8")
        self.year = year
        self.oneclick = oneclick
        if year==0:
            query = '{0} -cam'.format(title)
        else:
            query = '{0} {1} -cam'.format(title,year)

        self.dirs = furklib.searchFurk(query)
    def __init__(self, title, year, oneclick):
        Search.__init__(self)
        self.mediatype = 'Movie'
        self.title = title.encode("utf-8")
        self.year = year
        self.oneclick = oneclick
        if year == 0:
            query = '{0} -cam'.format(title)
        else:
            query = '{0} {1} -cam'.format(title, year)

        self.dirs = furklib.searchFurk(query)
Example #9
0
def SearchFromMenu(query):
	#xbmcplugin.setContent(int(sys.argv[1]), 'movies')
	dirs = furklib.searchFurk(query)
	if dirs:
		for dir in dirs:
			#if dir['is_ready']=='0':
			#	continue
			id = dir['info_hash']
			dirname = dir['name']
			url = sys.argv[0]+'?action=listFiles&id='+id

			if dir['is_ready']=='0':
				dirname = '[COLOR red]' + dirname + '[/COLOR]'
			
			if (dir.has_key('type') and dir['type'] == 'video' and dir.has_key('ss_urls') and dir.has_key('video_info')):			
				common.createFurkSearchListItem(dirname, True, url, dir['ss_urls'][4], dir['video_info'], id)
		common.endofDir()
	return
Example #10
0
def SearchDialog(type,title,year,season,number,go=False):
	global quality_options
	global quality_urls
	global quality_cleanname 
	global quality_ids
	global unquality_options
	global unquality_urls
	global unquality_cleanname
	global unquality_ids
	global unique_qualities

	if go:
		updateDialog = xbmcgui.DialogProgress()
		updateDialog.create("Streamcub Library", "Searching")
		updateDialog.update(20, "searching", title)	
	

	title = common.CleanFileName(title)

	if type=='Movie':
		if year==0:
			query = '{0} -cam'.format(title)
			dirs = furklib.searchFurk(query)
		else:
			query = '{0} {1} -cam'.format(title,year)
			dirs = furklib.searchFurk(query)
	elif type=='Show':

		query = '''{0} S{1:0>2}E{2:0>2}'''.format(title, season, number)
		dirs = furklib.searchFurk(query)
		
	else:
		query = title
		dirs = furklib.searchFurk(title)
	if go:
		updateDialog.close()
	k = 0
	found720p = False
	foundDvd = False
	foundAtleastOneCached = False
	if go:
		pDialog = xbmcgui.DialogProgress()
		pDialog.create('Searching for files')
	count = 0
	
	if dirs:
		for file in dirs:
			# Test some variables if they exist
			try:
				file['is_ready']
				file['size']
			except:
				continue
				pass

			count = count + 1
			percent = int(float(count * 100) / len(dirs))
			text = "%s files found ->" % len(quality_options) 
			for qual in unique_qualities:
				text = text + qual +','
			if go:
				pDialog.update(percent, text)
				if pDialog.iscanceled(): 
					pDialog.close()
					break

			if settings.getSetting('search_only_cached_files')=='true' and file['is_ready']=='0':
				continue
			id = file['info_hash']
			dirname = file['name']
			mysize = size(int(file['size']))
			valid = False

			#print ('Dirname ' + dirname)
			dirname =  common.CleanFileName(dirname)

			if type=='Show':

				myParser= guess_series(dirname)
				if myParser:
					myParser.parse()
					myName = myParser.name 
					mySeason = myParser.season
					myNumber = myParser.episode
					myYear = 0
					myNametoCheck = common.CleanFileName(myName).lower().replace(' ','')
					titletoCheck = common.CleanFileName(title).lower().replace(' ','')
					if myParser.quality: myquality = myParser.quality
					movie_name =  '''{0} {1} S{2:0>2}E{3:0>2}'''.format(myquality,myNametoCheck, mySeason, myNumber)					
					
					if int(mySeason) <> int(season):
						break
					elif titletoCheck == myNametoCheck and int(mySeason)==int(season) and int(myNumber)==int(number) and myquality.value>0:
						valid= True

					#Notification(mycheck.lower(),query.lower())
					if valid:
						if file['is_ready']=='0':
							movie_name =  '[COLOR red]' + dirname + '[/COLOR]'
						else:
							movie_name =  dirname
							foundAtleastOneCached = True

						#Notification('Quality:',str(myquality))
						quality_options.append('[' + mysize + '] '+str(myquality) + ' ' + movie_name)
						quality_ids.append(file['info_hash'])
						quality_cleanname.append(dirname)
						quality_urls.append(None)
						if not str(myquality) in unique_qualities:
							unique_qualities.append(str(myquality))
				else:
					# Notification ('cannot parse' , dirname)
					continue
	
			elif type=='Movie':
				valid = False
				parser = MovieParser()
				parser.data = dirname
				parser.parse()
				myName = parser.name 
				myYear = parser.year
				myquality = parser.quality
				movie_name = ''
				if file['is_ready']=='0':
					if file.has_key('type') and file['type'] == 'video':
						movie_name =  '[COLOR red]' + str(myquality) + ' ' + dirname + '[/COLOR]'
					else:
						continue
				else:
					movie_name = str(myquality) + ' ' + dirname
				movie_name2 = str(myquality) + ' ' + title.strip() + ' (' + str(year) + ')'
			

				if int(settings.getSetting('file_size_filter')) > 0 and int(file['size']) > (int(settings.getSetting('file_size_filter')) * 1024 * 1024 * 1024):
					continue

				if year==0 and title.lower() in myName.lower():
					valid = True
				if not myYear:
					myYear = 0
					valid = False
				title = unicodedata.normalize('NFKD',unicode(title,'utf-8')).encode('ASCII', 'ignore')
				#print 'T:' + title.lower()
				#print 'M:' + myName.lower() 
				if title.lower() in myName.lower() and myquality.value>250:
					valid = True

				if valid:
					quality_options.append('[' + mysize + '] '+ movie_name)
					quality_cleanname.append(dirname)
					quality_ids.append(file['info_hash'])
					if not str(myquality) in unique_qualities:
						unique_qualities.append(str(myquality))
					
				else:
					unquality_options.append(str(myquality) + ' ' + dirname)
					unquality_ids.append(file['info_hash'])
					unquality_cleanname.append(dirname)

			

	if not foundAtleastOneCached and type=='Show':
		season_episode = "s%.2de%.2d" % (int(season), int(number))
		season_episode2 = "%d%.2d" % (int(season), int(number))
	
		tv_show_season = "%s season %d" % (title, int(season))
		tv_show_episode = "%s %s" % (title, season_episode)

		dirs2 = []
		try:
			dirs2.extend(furklib.searchFurk(tv_show_episode))
		except:
			pass
		try:
			dirs2.extend(furklib.searchFurk(tv_show_season))
		except:
			pass

		# dirs2 = files
		titletoCheck = re.sub(r'\([^)]*\)', '', title)
		titletoCheck = common.CleanFileName(titletoCheck).lower()

		dir_names = []
		dir_ids = []
		
		count = 0

		for d in dirs2:
			
			count = count + 1
			percent = int(float(count * 100) / len(dirs2))
			text = "%s files found ->" % len(quality_options) 
			for qual in unique_qualities:
				text = text + qual +','
			if go:
				pDialog.update(percent, text)
			if pDialog.iscanceled(): 
				pDialog.close()
				break

			if settings.getSetting('search_only_cached_files')=='true' and d['is_ready']=='0':
				continue
			
			dirnametoCheck=common.CleanFileName(d['name']).lower()
			print 'title:'+titletoCheck
			print 'dirname:'+dirnametoCheck
			if dirnametoCheck.startswith(titletoCheck) and 'season' in dirnametoCheck and str(season) in dirnametoCheck:
				print 'filebyfile for:'+dirnametoCheck
				filebyfile(False,d['info_hash'],d['name'],title,year,season,number)
			
		
		for d in dirs2:
			if d['is_ready']=='0':
				continue
			if not (d['name'].lower().startswith(title.lower())):
				continue
			dir_names.append(d['name'])
			dir_ids.append(d['info_hash'])
					
		
		if len(dir_names)>0:
			idx = 0
			for dirname in dir_names:
				id = dir_ids[idx]
				idx = idx + 1 
				filebyfile(False,id,dirname,title,year,season,number)
				if pDialog.iscanceled(): 
					pDialog.close()
	        		break
		else:
			pass

	if go:	
		pDialog.close()
	
	if len(quality_options) >= 1:
		dialog = xbmcgui.Dialog()
		quality_select = dialog.select('Select quality', quality_options)
	else:
		quality_select = -1
	
	if len(quality_options) == 0:
		dialog = xbmcgui.Dialog()	
		dialog.ok("Error", "Nothing found", "" )	

	# common.Notification ('Selected' , str(quality_select))
	if quality_select == -1:
		return None,None
	else:
		if type=='Show':
			
			try:
				myurl = quality_urls[quality_select]
				if myurl:
					myname = quality_cleanname[quality_select]
				else:
					raise Exception("empty url")
			except: 
				myid = quality_ids[quality_select]
				files = furklib.fileInfo(myid)
				
				if not files:
					download(myid)
					return None,None
				
				k = k + 1
				for f in files:
					myname = f['name']
					#print myname
					if 'sample' in myname.lower():
						continue
					if myname.endswith('avi') or myname.endswith('mkv') or myname.endswith('mp4') or myname.endswith('wmv'):
						myurl = f['url_dl']
						break
					else:
						continue
								
		elif type=='Movie':
			myid = quality_ids[quality_select]
			files = furklib.fileInfo(myid)
			myurl = None
			if not files:
				download(myid)
				return None,None
			
			for f in files:
				myname = f['name'].lower()
				#print myname
				if 'sample' in myname or int(f['length']) < 30:
					continue
				if myname.endswith('avi') or myname.endswith('mkv') or myname.endswith('mp4') or myname.endswith('iso') or myname.endswith('wmv'):
					myurl = f['url_dl']
					myname = f['name']
					break
				else:
					continue

		#common.Notification('Found',myname)
		if myurl:
			return myname,myurl
		else:
			common.Notification('Not Found' , 'Please try again')
			return None,None