def main(*args, **kwargs):
	rhythm_obj=bus.get_object("org.gnome.Rhythmbox", "/org/gnome/Rhythmbox/Player")
	rhythmshell_obj=bus.get_object("org.gnome.Rhythmbox", "/org/gnome/Rhythmbox/Shell")
	rhythm=dbus.Interface(rhythm_obj, "org.gnome.Rhythmbox.Player")
	rhythmshell=dbus.Interface(rhythmshell_obj, "org.gnome.Rhythmbox.Shell")	
	artist=str(rhythmshell.getSongProperties(rhythm.getPlayingUri())['artist'])
	title=str(rhythmshell.getSongProperties(rhythm.getPlayingUri())['title'])

	searchstr='''"'''+title+'''"'''+' '+artist+' lyrics -search'
	
	gs=GoogleSearch(searchstr)
	print 'Googling for ',searchstr
	gs.results_per_page=10
	
	try:
		results=gs.get_results()
	except:
		# os.popen("dcop amarok contextbrowser showLyrics '<lyric>Google.com is not accessible. Check your internet connection and retry</lyric>'")
		print 'google.com is not accessible'
		return ''

	for res in results:
		lyric=getlyric(res.url.encode('utf8'),title)
		if lyric=='':
			pass
		else :
			print 'the lyric is:\n%s'%lyric
			break
Exemple #2
0
def main(*args, **kwargs):
	rhythm_obj=bus.get_object("org.gnome.Rhythmbox", "/org/gnome/Rhythmbox/Player")
	rhythmshell_obj=bus.get_object("org.gnome.Rhythmbox", "/org/gnome/Rhythmbox/Shell")
	rhythm=dbus.Interface(rhythm_obj, "org.gnome.Rhythmbox.Player")
	rhythmshell=dbus.Interface(rhythmshell_obj, "org.gnome.Rhythmbox.Shell")	
	artist=str(rhythmshell.getSongProperties(rhythm.getPlayingUri())['artist'])
	title=str(rhythmshell.getSongProperties(rhythm.getPlayingUri())['title'])

	searchstr='''"'''+title+'''"'''+' '+artist+' lyrics -search'
	
	gs=GoogleSearch(searchstr)
	print 'Googling for ',searchstr
	gs.results_per_page=10

	results=gs.get_results()
	print "got results", results

#	try:
#		results=gs.get_results()
#	except:
#		print 'google.com is not accessible'
#		return ''

	for res in results:
		lyric=getlyric(res.encode('utf8'))
		if lyric=='':
			pass
		else :
			print 'the lyric is:\n%s'%lyric
			break
Exemple #3
0
def GetSearchResults(query=None,type=None, exact=False):
	
	if (type=="movies"):
		# This a google search. The -tv will ommit all TV shows.
		search = 'intitle:%s -"Episode List" -"Series Rating"' % (query)
	else:
		search = 'allintitle:%s "Episode List"' % (query)
	
	gs = GoogleSearch(search)
	gs.results_per_page = 25
	gs.page = 0
	results = gs.get_results() +  gs.get_results()
	items = []
	
	for res in results:
	
		name = re.sub(
			'(<em>|</em>|<a>|</a>|DivX|-|icefilms(\.info)?|<b>\.\.\.</b>|Episode List|links)',
			'',
			res.title.encode('utf8')
		).strip()

		url=res.url
		video_url = re.search("icefilms\.info(/.*)", url).group(1)
		
		res = {}
		
		res['type'] = type
		res['title'] = name

		match = re.search("(.*)\((\d*)\)", res['title'])
		
		if (match):
			res['title'] = match.group(1).strip()
			res['year'] = int(match.group(2).strip())
			
		res['id'] = video_url
		
		items.append(res)
	
	return items
def search(a):
  try:
    gs = GoogleSearch(a)
    gs.results_per_page = 100
    results = gs.get_results()
    for res in results:
      print res.title.encode("utf8")
      print res.desc.encode("utf8")
      print res.url.encode("utf8")
      print
  except SearchError, e:
    print "Search failed:"
Exemple #5
0
def GetSearchResults(query=None, type=None, exact=False):

    if (type == "movies"):
        # This a google search. The -tv will ommit all TV shows.
        search = 'intitle:%s -"Episode List" -"Series Rating"' % (query)
    else:
        search = 'allintitle:%s "Episode List"' % (query)

    gs = GoogleSearch(search)
    gs.results_per_page = 25
    gs.page = 0
    results = gs.get_results() + gs.get_results()
    items = []

    for res in results:

        name = re.sub(
            '(<em>|</em>|<a>|</a>|DivX|-|icefilms(\.info)?|<b>\.\.\.</b>|Episode List|links)',
            '', res.title.encode('utf8')).strip()

        url = res.url
        video_url = re.search("icefilms\.info(/.*)", url).group(1)

        res = {}

        res['type'] = type
        res['title'] = name

        match = re.search("(.*)\((\d*)\)", res['title'])

        if (match):
            res['title'] = match.group(1).strip()
            res['year'] = int(match.group(2).strip())

        res['id'] = video_url

        items.append(res)

    return items
Exemple #6
0
def find(food_name):
	try:
	  print "Got" + str(food_name)
	  gs = GoogleSearch(food_name)
	  gs.results_per_page = 10
	  results = gs.get_results()
	  #print results
	  lines = []
	  for res in results:
	    lines.append(res.encode("utf8"))
	  
	  return lines
	except SearchError, e:
	  print "Search failed: %s" % e
Exemple #7
0
    def search(self, keyword, domain, numberOfResults=50, maxRequest=-1):
        """
        Google for a specific keyword
        :param keyword: The keyword
        :param domain: Constants defined by Googler (DOMAIN_ENGLISH, DOMAIN_VIETNAMESE ...)
        :param numberOfResults: Number of results to return
        :param maxRequest: Maximum search requests to make. If it's set to -1,
                        we'll take infinite requests to search
        :return: List of GoogleResult instances
        """
        # a trick to make Google not ban us for requesting so often
        keyword = keyword.replace(u' ', u'+')
        keyword = u'"%s"' % keyword  # quote it

        gs = GoogleSearch(query=keyword, tld=domain)
        gs.results_per_page = Googler.__RESULT_PER_PAGE

        ret = []
        requestCount = 0
        try:
            while True:
                results = gs.get_results()
                if not results or len(results) == 0:
                    return ret

                for result in results:
                    g = GoogleResult()
                    g.description = result.desc
                    g.url = result.url
                    g.title = result.title
                    if self.parse(g):
                        ret.append(g)
                        if len(ret) == numberOfResults:
                            return ret

                # sleep before conducting another search
                time.sleep(5)

                if maxRequest != -1:
                    requestCount += 1
                    if requestCount > maxRequest:
                        return ret

        except SearchError as e:
            print "Search failed: %s" % e

        return ret
Exemple #8
0
	def find_lyric(self,title,artist,is_first=False,is_next=False,is_prev=False):
		if is_first==True:
			self.result_no=-1
			self.all_lyrics=[]
			searchstr='''"'''+title+'''"'''+' '+artist+' lyrics -search'
			gs=GoogleSearch(searchstr)
			print 'Googling for ',searchstr
			self.results=gs.get_results()
			print "the search results are: "
			for i in self.results:
				print i

		if is_prev==True:
			if self.result_no>=1:
				self.result_no-=1
				print "returning the lyric no %d"%self.result_no
				return self.all_lyrics[self.result_no]
			else:
				return "This is the first one"
		
		if is_next==True:
			if len(self.all_lyrics)>self.result_no+1:
				self.result_no+=1
				return self.all_lyrics[self.result_no]

		while self.result_no+1<len(self.results):
			self.result_no+=1
			lyric=getlyric(self.results[self.result_no].encode('utf8'))
			self.all_lyrics.append(lyric)
		
			if lyric=='':
				pass
			else :
				print "result_no is %d"%self.result_no
				return lyric
		else:
			return "this is the last lyric I could find"
Exemple #9
0
def main():
	artist=get('dcop %s player artist'%amarokid).strip()
	title=get('dcop %s player title'%amarokid).strip()

	if title =='':
		searchstr=get('dcop %s player nowPlaying'%amarokid)+' lyrics'
	else :
		searchstr='''"'''+title+'''"'''+' '+artist+' lyrics'

	gs=GoogleSearch(searchstr)
	print 'Googling for ',searchstr
	gs.results_per_page=10
	try:
		results=gs.get_results()
	except:
		os.popen("dcop %s contextbrowser showLyrics '<lyric>Google.com is not accessible. Check your internet connection and retry</lyric>'"%amarokid)
		print 'google.com is not accessible'
		return ''

	xml=open('%s/tmp.xml'%user.home,'w')
	for res in results:
		lyric=getlyric(res.url.encode('utf8'),title)
		if lyric=='':
			pass
		else :
			print 'the lyric is:\n%s'%lyric
			xmldoc=xmlcorrect(lyric)
			xmldoc="""<lyric artist="%s" title="%s" page_url="%s" >"""%(artist,title,res.url.encode('utf8'))+xmldoc+'</lyric>'
			print >> xml, xmldoc
			xml.close()
			sh=open('%s/tmp.sh'%user.home,'w')
			print >> sh, "xml=$(cat ~/tmp.xml)"
			print >> sh, '''dcop %s contextbrowser showLyrics "${xml}"'''%amarokid
			sh.close()
			get("sh %s/tmp.sh"%user.home)
			break
Exemple #10
0
#!/usr/bin/python
#
# This program does a Google search for "quick and dirty" and returns
# 50 results.
#

from search import GoogleSearch, SearchError
try:
  gs = GoogleSearch("quick and dirty")
  gs.results_per_page = 50
  results = gs.get_results()
  for res in results:
    print res.title.encode('utf8')
    print res.desc.encode('utf8')
    print res.url.encode('utf8')
    print
except SearchError, e:
  print "Search failed: %s" % e