예제 #1
0
파일: chemical.py 프로젝트: Sighter/remeta
	def search(self, term):
		# define link for search
		searchUrl = self.baseUrl + r"/sc/search?&must=" + term + r"&Type=Music&Type=&inandout=true&SRI=true&ND=-1"
		

		print(" --> searching on chemical for " + term)
		print(" --> with " + searchUrl)
		source = getWebAsStr(searchUrl)

		# create a parser, we use minidom
		p = html5lib.HTMLParser(tree=treebuilders.getTreeBuilder("dom"))
		dom_tree = p.parse(source)
		walker = treewalkers.getTreeWalker("dom")
		stream = walker(dom_tree)

		# now we can send the stream to our fetcher functions
		# find links on search result page
		l_hitLinks = self.fetch_HitLinks(stream)

		# find short info
		l_shortInfo = self.fetch_ShortInfo(stream)

		# create an two dimensional list
		results = []

		for link, info in zip(l_hitLinks, l_shortInfo):
			results.append([link, info]) 

		return results
예제 #2
0
파일: chemical.py 프로젝트: Sighter/remeta
	def getReleaseInfo(self, rel):
		sFktname = "getReleaseInfo"
		
		source = getWebAsStr(rel.infopage)

		
		

		# create a parser, we use minidom
		p = html5lib.HTMLParser(tree=treebuilders.getTreeBuilder("dom"))
		dom_tree = p.parse(source)
		walker = treewalkers.getTreeWalker("dom")
		stream = walker(dom_tree)

		# get catid
		rel.catid = self.fetch_Catid(stream)

		# get tunelist
		l_tuneList = self.fetch_TuneInfo(stream)

		# build release tune list
		for tune in l_tuneList:
			temp = track()
			temp.link = tune[0]
			temp.artist = tune[1]
			temp.title = tune[2]
			temp.key = tune[3]
			rel.tunes.append(temp)

		# build links
		p = ""
		for tune in rel.tunes:
			# downloading file there links are in
			try:
				f = urllib.request.urlopen(self.baseUrl + tune.link).read()
				p = "/tmp/pymyrel-tmpinfo"
				
			except:
				print(" --> chemical.getReleaseInfo: An Error occured, while downloading linkfile")

			if p != "":
				output = open(p ,'wb')
				output.write(f)
				output.close()
				linkfile = open(p, 'r')
				for line in linkfile:
					if line.startswith("http://") == True:
						tune.link = line.strip("\n")

		if len(rel.tunes) > 0:
			print(rel)

		return rel