def parse(self, useParentFoldernameAsSearchstring=False):
		printl("->", self, "S")
		absFilename = self.Path + u"/" + self.Filename + u"." + self.Extension
		name = self.Filename.lower()
		self.SearchString = name
		valerieInfoSearchString = None
		isSeasonEpisodeFromFilename = False
		isE2Recording = (self.Extension == u"ts") and (self.isEnigma2Recording(absFilename))
		# Avoid Null Titles		
		if self.Title is None or self.Title == "":
			self.Title = self.Filename
		
		if self.isValerieInfoAvailable(self.Path) is True:
			valerieInfoSearchString = self.getValerieInfo(self.Path).strip()
			printl("Found valerie.info containing: " + str(Utf8.utf8ToLatin(valerieInfoSearchString)), self)
			if valerieInfoSearchString == u"ignore":
				printl("<- found 'ignore'... Returning to sync process and skipping!", self, "I")
				return False
			if self.searchForImdbAndTvdbId(valerieInfoSearchString):
				valerieInfoSearchString = None
		#################### DVD #####################
		
		if self.Extension.lower() == u"ifo":
			dirs = self.Path.split(u"/")
			#vidoets = dirs[len(dirs) - 1]
			printl("dirs=" + str(dirs), self)
			self.SearchString = dirs[len(dirs) - 1] 	# /DVDs/title/VIDEO_TS.ifo
			if self.SearchString.upper() == u"VIDEO_TS":	
				self.SearchString = dirs[len(dirs) - 2]	# /DVDs/title/VIDEO_TS/VIDEO_TS.ifo
			self.SearchString = self.SearchString.lower()
			printl("DVD: " + str(Utf8.utf8ToLatin(self.SearchString)), self)
			#return True
		
		#################### DVD ######################
		
		#################### BDMV #####################
		
		if self.Extension.lower() == u"m2ts":
			dirs = self.Path.split(u"/")
			printl("dirs=" + str(dirs), self)
			if dirs[len(dirs) - 1] == "STREAM":
				if dirs[len(dirs) - 2] == "BDMV": #title/BDMV/STREAM/00000.m2ts
					self.SearchString = dirs[len(dirs) - 3]
				else: #title/STREAM/00000.m2ts
					self.SearchString = dirs[len(dirs) - 2]
				self.SearchString = self.SearchString.lower()
				self.Resolution = u"1080p" # Are all bluray in 1080p?
				self.Sound = u"dts" # Are all bluray in DTS
				printl("BDMV: " + str(Utf8.utf8ToLatin(self.SearchString)), self)
				
		
		#################### BDMV ######################
		
		### Replacements PRE
		printl("Replacements PRE on " + str(self.SearchString), self, "I")
		step = 1
		for replacement in replace.replacements(u"pre"):
			old = self.SearchString
			self.SearchString = resub(replacement[0], replacement[1], self.SearchString)
			printl("\tStep %d: %s -> %s = %s -> %s" % (step, str(replacement[0].pattern), str(replacement[1]), old, self.SearchString), self, "I")
			step = step + 1
		
		printl(":-1: " + str(Utf8.utf8ToLatin(self.SearchString)), self)
		
		### Check for IMDb-ID in filename
		printl("Check for IMDb-ID in filename '" + name + "'", self, "I")
		
		self.searchForImdbAndTvdbId(name)
		
		if self.isNfoAvailable(self.Path + u"/" + self.Filename):
			printl("nfo File present - now parsing: " + self.Path + u"/" + self.Filename, self, "I")
			result = self.parseNfo(self.Path + u"/" + self.Filename)
			if result is not None:
				printl(" => nfo File successfully parsed!", self, "I")
				#self.isMovie = result.isMovie
				#self.isEpisode = result.isEpisode
				#self.isSerie = result.isSerie
				self.MediaType = result.MediaType
				
				self.TheTvDbId = result.TheTvDbId
				self.ImdbId = result.ImdbId
				self.Title = result.Title
				self.Plot = result.Plot
				
				self.Season = result.Season
				self.Episode = result.Episode
				
				self.Year = result.Year
				self.Genres = result.Genres
				self.Runtime = result.Runtime
				
				if self.isXbmcNfo == True and self.ImdbId is not None:
					printl("<- XBMC-style nfo found...", self, "I")
					return True
			else:
				printl("Something went wrong while reading from nfo :-(", self, "I")
		
		###  
		if (self.Year == None) and (isE2Recording == False):
			m = re.search(r'\s(?P<year>\d{4})\s', self.SearchString)
			if m and m.group("year"):
				year = int(m.group("year"))
				printl("year=" + str(year), self)
				if year > 1940 and year < 2012:
					self.Year = year
					# removing year from searchstring
					#self.SearchString = replace(str(year), u" ", self.SearchString)
					#self.SearchString = name[:m.start()]
		
		printl(":0: " + str(Utf8.utf8ToLatin(self.SearchString)), self)
		
		###	
		m = re.search(r'720p', name)
		if m:
			self.Resolution = u"720p"
		else:
			m = re.search(r'1080i', name)
			if m:
				self.Resolution = u"1080i"
			else:
				m = re.search(r'1080p', name)
				if m:
					self.Resolution = u"1080p"
		
		###	
		m = re.search(r'dts', name)
		if m:
			self.Sound = u"dts"
		else:
			m = re.search(r'dd5', name)
			if m:
				self.Sound = u"ac3"
			else:
				m = re.search(r'ac3', name)
				if m:
					self.Sound = u"ac3"
		
		#nameConverted = name
		
		if not self.isTypeMovie():
			printl("(isMovie is False) => assuming TV show - trying to get season and episode from SearchString: " + self.SearchString, self, "I")
			
			## trying a global expression
			#	m = re.search(r'\W(s(?P<season>\d+))?\s?(d(?P<disc>\d+))?\s?(e(?P<episode>\d+))?([-]?\s?e?(?P<episode2>\d+))?(\D|$)' , self.SearchString)
			
			##### 
			#####  s03d05e01-e05 - Season 3 Disc 5 Episode 1 [to Episode 5]
			#####  s01d02e03     - Season 3 Disc 5 Episode 1
			#####  s01d02	     - Season 3 Disc 5 
			#####			Seinfeld.S08D03.PAL.DVDR		
			if self.Season == None or self.Episode == None:
				#m =re.search(r'\Ws(?P<season>\d+)\s?d(?P<disc>\d+)\s?e(?P<episode>\d+)[-]\s?e?(?P<episode2>\d+)(\D|$)', self.SearchString)
				m = re.search(r'\Ws(?P<season>\d+)\s?d(?P<disc>\d+)\s?(e(?P<episode>\d+))?([-]e?(?P<episode2>\d+))?(\D|$)', self.SearchString)				
			#	m = re.search(r'\Ws(?P<season>\d+)\s?d(?P<disc>\d+)(\D|$)', self.SearchString)
				if m and m.group("season") and m.group("disc"):
					#printl("PARSE RESULT 1:"+str(str(m.group("disc")))+" "+str(m.group("episode"))+" "+str(m.group("episode2")), self)
					self.setMediaType(self.SERIE)
					
					# Issue #474, efo
					isSeasonEpisodeFromFilename = True
					self.Season = int(m.group("season"))
					self.Disc = int(m.group("disc"))
					if m.group("episode") is not None:
						self.Episode = int(m.group("episode"))
					if m.group("episode2") is not None:
						self.EpisodeLast = int(m.group("episode2"))
					
					self.SearchString = resub(r's(?P<season>\d+)\s?d(?P<disc>\d+)\s?(e(?P<episode>\d+))?([-]e?(?P<episode2>\d+))?.*', u" ", self.SearchString)
			
			#####
			#####  s03d05 - Season 3 Disc 5
			#####			
			#if self.Season == None or self.Episode == None:
			#	m = re.search(r'\Ws(?P<season>\d+)\s?d(?P<disc>\d+)(\D|$)', self.SearchString)
			#	if m and m.group("season") and m.group("disc"):
			#		printl("PARSE RESULT 3:", self)
			#		self.setMediaType(self.SERIE)
			#		
			#		self.Season = int(m.group("season"))
			#		self.Disc = int(m.group("disc"))
			#		self.Episode = 0
			#		
			#		self.SearchString = resub(r's(?P<season>\d+)\s?d(?P<disc>\d+).*', u" ", self.SearchString)
			#
			#####
			#####  s03e05e06 s03e05-e06 s03e05-06 s03e05 06
			#####  s03e05
			#####
			if self.Season == None or self.Episode == None:
				#m = re.search(r'\Ws(?P<season>\d+)\s?e(?P<episode>\d+)[-]?\s?e?(?P<episode2>\d+)(\D|$)', self.SearchString)
				#Issue #494, efo => with the "\Ws" expression PVMC doesn't detect season / episodes if pattern is 
				#located at the beginning of string, for example like "s01e02 - title.avi"
				#m = re.search(r'\Ws(?P<season>\d+)\s?e(?P<episode>\d+)([-]?\s?e?(?P<episode2>\d+))?(\D|$)', self.SearchString)
				m = re.search(r'(?P<season>\d+)\s?e(?P<episode>\d+)([-]?\s?e?(?P<episode2>\d+))?(\D|$)', self.SearchString)
				if m and m.group("season") and m.group("episode"):
					#printl("PARSE RESULT 4:"+str(m.group("episode"))+" "+str(m.group("episode2")), self)
					self.setMediaType(self.SERIE)
					
					self.Season = int(m.group("season"))
					self.Episode = int(m.group("episode"))
					# Issue #474, efo
					isSeasonEpisodeFromFilename = True
					if m.group("episode2") is not None:
						self.EpisodeLast = int(m.group("episode2"))
					
					self.SearchString = resub(r's(?P<season>\d+)\s?e(?P<episode>\d+)([-]?\s?e?(?P<episode2>\d+))?.*', u" ", self.SearchString)
				
			#####
			#####  s03e05
			#####
			#
			#if self.Season == None or self.Episode == None:
			#	m = re.search(r'\Ws(?P<season>\d+)\s?e(?P<episode>\d+)(\D|$)', self.SearchString)
			#	if m and m.group("season") and m.group("episode"):
			#		printl("PARSE RESULT 5:", self)
			#		self.setMediaType(self.SERIE)
			#		isSeasonEpisodeFromFilename = True
			#		
			#		self.Season = int(m.group("season"))
			#		self.Episode = int(m.group("episode"))
			#		
			#		printl("PARSE RESULT 5: " + self.SearchString, self)
			#		self.SearchString = resub(r's(?P<season>\d+)\s?e(?P<episode>\d+).*', u" ", self.SearchString)
			#		printl("PARSE RESULT 5: " + self.SearchString, self)
			#
			
			#####
			#####  e05
			#####
			if self.Season == None or self.Episode == None:
				m = re.search(r'\Ws?(e(?P<episode>\d+))([-]?\s?e?(?P<episode2>\d+))?(\D|$)', self.SearchString)
				if m and m.group("episode"):
					self.setMediaType(self.SERIE)
					
					# Issue #474, efo
					isSeasonEpisodeFromFilename = True
					self.Season = 0
					self.Episode = int(m.group("episode"))
					if m.group("episode2") is not None:
						self.EpisodeLast = int(m.group("episode2"))
					
					
					self.SearchString = resub(r's?(e(?P<episode>\d+))([-]?\s?e?(?P<episode2>\d+))?.*', u" ", self.SearchString)			
			#####
			#####  d05 - Disc 5
			#####			
			if self.Season == None or self.Episode == None:
				m = re.search(r'\Wd(?P<disc>\d+)(\D|$)', self.SearchString)
				if m and m.group("disc"):
					#printl("PARSE RESULT 3:", self)
					self.setMediaType(self.SERIE)
					
					# Issue #474, efo
					isSeasonEpisodeFromFilename = True
					self.Season = 0
					self.Disc = int(m.group("disc"))
					self.Episode = 0
					
					self.SearchString = resub(r'd(?P<disc>\d+).*', u" ", self.SearchString)

			#####
			#####  3x05
			#####
			
			if self.Season == None or self.Episode == None:  
				m = re.search(r'\D(?P<season>\d+)x(?P<episode>\d+)(\D|$)', self.SearchString)
				if m and m.group("season") and m.group("episode"):
					self.setMediaType(self.SERIE)
					
					# Issue #474, efo
					isSeasonEpisodeFromFilename = True
					self.Season = int(m.group("season"))
					self.Episode = int(m.group("episode"))
					
					self.SearchString = resub(r'(?P<season>\d+)x(?P<episode>\d+).*', u" ", self.SearchString)
			
			#####
			#####  part 3
			#####
			
			if self.Season == None or self.Episode == None:
				m = re.search(r'\W(part|pt)\s?(?P<episode>\d+)(\D|$)', self.SearchString)
				if m and m.group("episode"):
					self.setMediaType(self.SERIE)
					
					# Issue #474, efo
					isSeasonEpisodeFromFilename = True
					self.Season = int(0)
					self.Episode = int(m.group("episode"))
					
					self.SearchString = resub(r'(part|pt)\s?(?P<episode>\d+).*', u" ", self.SearchString)
			
			#####
			#####  305
			#####
			
			if self.Season == None or self.Episode == None:
			
				nameConverted = u""
				prevc = u"a"
				for c in self.SearchString:
					if (prevc.isdigit() and c.isdigit()) or (prevc.isdigit() is False and c.isdigit() is False):
						nameConverted += c
					else:
						nameConverted += " " + c
					prevc = c
				
				printl("[[[ " + str(Utf8.utf8ToLatin(nameConverted)), self)
				
				nameConverted = nameConverted.strip()
				
				m = re.search(r'\D(?P<seasonepisode>\d{3,4})(\D|$)', nameConverted)
				if m and m.group("seasonepisode"):
					se = int(-1)
					s = int(-1)
					e = int(-1)
					
					se = int(m.group("seasonepisode"))
					
					s = se / 100
					e = se % 100
					
					if (s == 2 and e == 64 or s == 7 and e == 20 or s == 10 and e == 80 or s == 0 or s == 19 and e >= 40 or s == 20 and e <= 14) is False:
						self.setMediaType(self.SERIE)
						
						self.Season = s
						self.Episode = e
						
						self.SearchString = resub(r'(?P<seasonepisode>\d{3,4}).*', u" ", nameConverted)
		
		if self.Disc == 0:
			self.Disc = None
		if self.Episode == 0:
			self.Episode = None
			
		
		printl(":2: " + str(Utf8.utf8ToLatin(self.SearchString)) + " " + str(self.Season) + " " + str(self.Episode) + " " + str(self.Year), self)
		
		if isE2Recording is True:
			printl("Extension == 'ts' and E2 meta file found => retrieving name from '" + absFilename + "'", self, "I")
			e2info = self.getEnigma2RecordingName(absFilename)
			if e2info is not None:
				printl("e2info: "+ str(Utf8.utf8ToLatin(e2info.MovieName)) + " - " + str(Utf8.utf8ToLatin(e2info.EpisodeName) + "," + str(e2info.IsMovie) + "," + str(e2info.IsEpisode)), self)
				if e2info.IsMovie:
					if self.getMediaType() == self.SERIE:
						printl("E2-Info assumes 'MOVIE' - but foldertype is set to 'TV' => using 'TV'...", self, "I")
						self.SearchString = "\"" + e2info.MovieName +"\"" +  ":: " + "\"" + e2info.EpisodeName + "\""
					else:
						printl("Assuming Movie...", self, "I")
						self.SearchString = e2info.MovieName
						self.setMediaType(self.MOVIE) 
				elif e2info.IsEpisode:
					if self.getMediaType() == self.MOVIE:
						printl("E2-Info assumes 'TV' - but foldertype is set to 'MOVIE' => using 'MOVIE'...", self, "I")
						self.SearchString = e2info.MovieName
					else:
						# Issue #205, efo => since we have dedicated name + episode name use quotes to enhance google search result
						self.SearchString = "\"" + e2info.MovieName +"\"" +  ":: " + "\"" + e2info.EpisodeName + "\""
						printl("Assuming TV-Show...", self, "I")
						if isSeasonEpisodeFromFilename == False:
							printl("Season / episode seem not to be retrieved from filename => resetting...", self, "I")
							self.Season = None
							self.Episode = None
						self.setMediaType(self.SERIE)
					
				self.isEnigma2MetaRecording = True
				printl("<- Returning to sync process using E2 meta-file SearchString '" + str(Utf8.utf8ToLatin(self.SearchString)) + "'", self)
				return True
		
		if valerieInfoSearchString is not None:
			self.SearchString = valerieInfoSearchString
			printl("<- Returning to sync process using valerie.info SearchString '" + str(Utf8.utf8ToLatin(self.SearchString)) + "'", self)
			return True
		
		if not self.isTypeSerie():
			self.setMediaType(self.MOVIE)
		
		# So we got year and season and episode 
		# now we can delete everything after the year
		# but only if the year is not the first word in the string
		if self.Year is not None:
			printl("Adapt SearchString due to year...", self, "I")
			pos = self.SearchString.find(str(self.Year))
			if pos > 0:
				self.SearchString = self.SearchString[:pos]
				printl(" => SearchString now set to '" + self.SearchString + "'", self, "I")
		
		#print ":1: ", self.SearchString
		### Replacements POST
		printl("rpost: " + str(Utf8.utf8ToLatin(self.SearchString)), self)
		self.SearchString = resub(r'[-]', u" ", self.SearchString)
		self.SearchString = resub(r' +', u" ", self.SearchString)
		printl("rpost:: " + str(Utf8.utf8ToLatin(self.SearchString)), self)
		
		self.SearchString = self.SearchString.strip()
		
		post = u"post"
		if self.isTypeSerie():
			post = u"post_tv"
		elif self.isTypeMovie():
			post = u"post_movie"
			
		for replacement in replace.replacements(post):
			#print "[" + post + "] ", replacement[0], " --> ", replacement[1]
			self.SearchString = resub(replacement[0], replacement[1], self.SearchString)
		
		if useParentFoldernameAsSearchstring:
			printl("Building search string from parent folder names...", self, "I")
			try:
				folders = self.Path.split("/")
				self.SearchString = folders[len(folders) - 1] 		# /DVDs/title/VIDEO_TS.ifo
				if self.SearchString.upper() == u"VIDEO_TS":	
					self.SearchString = folders[len(folders) - 2]	# /DVDs/title/VIDEO_TS/VIDEO_TS.ifo
				self.searchForImdbAndTvdbId(self.SearchString)
			except Exception, ex:
				printl("Exception: " + str(ex), self, "E")
	def parseNfoXbmc(self, lines):
		printl("", self)
		try:
			for line in lines:
				line = line.strip()
				try:
					print("starting xbmc nfo parsing", self, "D")
					if line.startswith("<id>"):
						line = line.replace("id", "")
						line = line.replace("<>", "")
						line = line.replace("</>", "")
						if lines[1].startswith("<movie"):
							self.setMediaType(self.MOVIE)
							
							self.ImdbId = line
						elif lines[1].startswith("<episodedetails>"):
							self.setMediaType(self.SERIE)
							
							self.TheTvDbId = line
					elif line.startswith("<title>"):
						line = line.replace("title", "")
						line = line.replace("<>", "")
						line = line.replace("</>", "")
						self.Title = line
					elif line.startswith("<season>"):
						line = line.replace("season", "")
						line = line.replace("<>", "")
						line = line.replace("</>", "")
						self.Season = int(resub(r'\D+', '', line))
					elif line.startswith("<episode>"):
						line = line.replace("episode", "")
						line = line.replace("<>", "")
						line = line.replace("</>", "")
						self.Episode = int(resub(r'\D+', '', line))
					elif line.startswith("<year>"):
						line = line.replace("year", "")
						line = line.replace("<>", "")
						line = line.replace("</>", "")
						self.Year = int(resub(r'\D+', '', line))
					elif line.startswith("<plot>"):
						line = line.replace("plot", "")
						line = line.replace("<>", "")
						line = line.replace("</>", "")
						self.Plot = line
					elif line.startswith("<runtime>"):
						line = line.replace("runtime", "")
						line = line.replace("<>", "")
						line = line.replace("</>", "")
						self.Runtime = int(resub(r'\D+', '', line))
					elif line.startswith("<genre>"):
						line = line.replace("genre", "")
						line = line.replace("<>", "")
						line = line.replace("</>", "")
						self.Genres = line
					elif line.startswith("<rating>"):
						line = line.replace("rating", "")
						line = line.replace("<>", "")
						line = line.replace("</>", "")
						self.Popularity = int(round(float(line)))
					elif line.startswith("<tagline>"):
						line = line.replace("tagline", "")
						line = line.replace("<>", "")
						line = line.replace("</>", "")
						self.Tag = line
					elif line.startswith("<codec>"):
						line = line.replace("codec", "")
						line = line.replace("<>", "")
						line = line.replace("</>", "")
						self.Sound = line
					elif line.startswith("<width>"):
						line = line.replace("width", "")
						line = line.replace("<>", "")
						line = line.replace("</>", "")
						self.Resolution = line
					elif line.startswith("<mpaa>"):
						printl("found mpaa tag", self, "D")
						line = line.replace("mpaa", "")
						line = line.replace("<>", "")
						line = line.replace("</>", "")
						self.mpaa = line
					elif line.startswith("<studio>"):
						printl("found studio tag")
						line = line.replace("studio", "")
						line = line.replace("<>", "")
						line = line.replace("</>", "")
						self.studio = line
				except Exception, ex:
					printl("Exception (in loop): " + str(ex), self, "E")
			return self