~davidc3/unity-books-lens/trunk

« back to all changes in this revision

Viewing changes to unity-books-daemon

  • Committer: David Callé
  • Date: 2011-05-04 21:00:33 UTC
  • Revision ID: davidc@framli.eu-20110504210033-3ugy2x1t6r91p3fc
* Don't duplicate information provided by icons.
* Don't advertise a Wikipedia article when it's probably not one.
* Get more answers from Wikipedia.
* On Focused Author, get the most possible answers from Google Books.
* The number of requested results have to be defined for each request rather than in API methods.
* New main icon.

Show diffs side-by-side

added added

removed removed

Lines of Context:
264
264
        # This method is used to clean the query provided by Zeitgeist
265
265
        # FIXME This should be tested with popular websites/applications/file naming schemes
266
266
        #
267
 
        query_crop = re.sub('[^a-zA-Z0-9 ].*', '', query)
 
267
        query = query.replace('YouTube - ', '')
 
268
        query_crop = re.sub('[^a-zA-Z0-9\' ].*', '', query)
268
269
        if len(query_crop) < 4:
269
270
            query_crop = re.sub('^[a-zA-Z0-9 ]{3,}[^a-zA-Z0-9 ]', '', query)
270
271
            query_crop = re.sub('[^a-zA-Z0-9 ].*', '', query_crop)
354
355
                    #print "    " + title
355
356
                    title = self.clean_title(title)
356
357
                    title = self.clean_title(title)
357
 
                    author = "Wikipedia article"
 
358
                    author = "Article"
358
359
                    model.append(url, icon_hint, group, "text/html",
359
360
                        title, author)
360
361
 
382
383
            # Make these results global for "author focus"
383
384
            global data_google
384
385
            data_google = api_fun_park.google_books_first_search("%s" % 
385
 
                search, 0)
 
386
                search, 0, 6)
386
387
            self.google_books_display(data_google, GROUP_BOOKS, model)
387
388
 
388
389
#
392
393
        if not (re.match(".*unknown.*", author_focus, flags=re.IGNORECASE)):
393
394
            author_focus_sane = "\"" + author_focus + "\""
394
395
            data_google = api_fun_park.google_books_search("inauthor:%s" % 
395
 
                author_focus_sane, 0)
 
396
                author_focus_sane, 0, 'large')
396
397
            self.google_books_display(data_google, GROUP_AUTHORS, model)
397
398
            
398
399
#
401
402
    def google_books_free_results(self, search, model):
402
403
        # Make these results global for "author focus"
403
404
        data_google = api_fun_park.google_books_first_search("%s" % 
404
 
            search, 1)
 
405
            search, 1, 6)
405
406
        self.google_books_display(data_google, GROUP_BOOKS, model)
406
407
            
407
408
#
411
412
        if not (re.match(".*unknown.*", author_focus, flags=re.IGNORECASE)):
412
413
            author_focus_sane = "\"" + author_focus + "\""
413
414
            data_google = api_fun_park.google_books_search("inauthor:%s" % 
414
 
                author_focus_sane, 1)
 
415
                author_focus_sane, 1, 'large')
415
416
            self.google_books_display(data_google, GROUP_AUTHORS, model)
416
417
                            
417
418
#
451
452
                if (icon_hint == ""):
452
453
                        icon_hint = Gio.ThemedIcon.new("stock_person").to_string()
453
454
                model.append(url, icon_hint, GROUP_AUTHORS, "text/html",
454
 
                    title, "Wikipedia article")
 
455
                    title, "Look up on Wikipedia")
455
456
 
456
457
#
457
458
# About Lens, the "?" query.