Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/GetIABooksActivity.py
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@sugarlabs.org>2011-04-06 20:04:25 (GMT)
committer Gonzalo Odiard <godiard@sugarlabs.org>2011-04-06 20:04:25 (GMT)
commit2abca143a54f25c0f77b23ee58789898d6b81be9 (patch)
treea1887a8dea422808915dc917ff5105f582fcf9c3 /GetIABooksActivity.py
parent6e6c2c2a05f6454d8aaeb355309aebc6679f5570 (diff)
In Internet Archive server try to download _test.pdf and if not present .pdf files
In Internet Archive server there are files with name ending in _test.pdf smaller than the .pdf files, but for not all the books.
Diffstat (limited to 'GetIABooksActivity.py')
-rwxr-xr-xGetIABooksActivity.py32
1 files changed, 21 insertions, 11 deletions
diff --git a/GetIABooksActivity.py b/GetIABooksActivity.py
index 86d4f18..c79f01b 100755
--- a/GetIABooksActivity.py
+++ b/GetIABooksActivity.py
@@ -573,12 +573,12 @@ class GetIABooksActivity(activity.Activity):
self.show_message(_('You must enter at least 3 letters.'))
self._books_toolbar.search_entry.grab_focus()
return
-
if self.source == 'Internet Archive':
self.queryresults = \
opds.InternetArchiveQueryResult(search_text,
query_language, self)
elif self.source in _SOURCES_CONFIG:
+ #if self.source in _SOURCES_CONFIG:
repo_configuration = _SOURCES_CONFIG[self.source]
self.queryresults = opds.RemoteQueryResult(repo_configuration,
search_text, query_language, self.window)
@@ -652,6 +652,7 @@ class GetIABooksActivity(activity.Activity):
gobject.idle_add(self.download_book, self.download_url)
def download_book(self, url):
+ logging.error('DOWNLOAD BOOK %s', url)
self.listview.props.sensitive = False
self._books_toolbar.search_entry.set_sensitive(False)
path = os.path.join(self.get_activity_root(), 'instance',
@@ -691,24 +692,33 @@ class GetIABooksActivity(activity.Activity):
while gtk.events_pending():
gtk.main_iteration()
- def set_downloaded_bytes(self, downloaded_bytes, total):
- fraction = float(downloaded_bytes) / float(total)
- self.progressbar.set_fraction(fraction)
-
- def clear_downloaded_bytes(self):
- self.progressbar.set_fraction(0.0)
-
def _get_book_error_cb(self, getter, err):
self.listview.props.sensitive = True
self.enable_button(True)
self.progressbox.hide()
_logger.debug("Error getting document: %s", err)
- self._show_error_alert(_('Error: Could not download %s. ' +
- 'The path in the catalog seems to be incorrect') %
- self.selected_title)
self._download_content_length = 0
self._download_content_type = None
self._getter = None
+ if self.source == 'Internet Archive' and \
+ getter.url.endswith('_text.pdf'):
+ # in the IA server there are files ending with _text.pdf
+ # smaller and better than the .pdf files, but not for all
+ # the books. We try to download them and if is not present
+ # download the .pdf file
+ self.download_url = self.download_url.replace('_text.pdf', '.pdf')
+ self.get_book()
+ else:
+ self._show_error_alert(_('Error: Could not download %s. ' +
+ 'The path in the catalog seems to be incorrect') %
+ self.selected_title)
+
+ def set_downloaded_bytes(self, downloaded_bytes, total):
+ fraction = float(downloaded_bytes) / float(total)
+ self.progressbar.set_fraction(fraction)
+
+ def clear_downloaded_bytes(self):
+ self.progressbar.set_fraction(0.0)
def process_downloaded_book(self, tempfile, suggested_name):
_logger.debug("Got document %s (%s)", tempfile, suggested_name)