diff -u -r -N '-x=*.pyc/*.*~' /home/dcastelo/Downloads/GetBooks.activity/get-books.cfg /home/dcastelo/Activities/GetBooks.activity/get-books.cfg
old
|
new
|
|
22 | 22 | name = Internet Archive |
23 | 23 | query_uri = http://bookserver.archive.org/catalog/opensearch?q= |
24 | 24 | opds_cover = http://opds-spec.org/image |
25 | | #opds_cover = http://opds-spec.org/image/thumbnail |
| 25 | |
| 26 | [Catalogs_Internet Archive] |
| 27 | Index = http://bookserver.archive.org/catalog/ |
| 28 | |
| 29 | [Ceibal] |
| 30 | name = Ceibal |
| 31 | query_uri = http://biblioteca.ceibal.edu.uy/latest.atom?q= |
| 32 | opds_cover = http://opds-spec.org/cover |
| 33 | summary_field = summary |
| 34 | |
| 35 | [Catalogs_Ceibal] |
| 36 | indice = http://biblioteca.ceibal.edu.uy/static_media/catalogo_inicial.htm |
diff -u -r -N '-x=*.pyc/*.*~' /home/dcastelo/Downloads/GetBooks.activity/GetIABooksActivity.py /home/dcastelo/Activities/GetBooks.activity/GetIABooksActivity.py
old
|
new
|
|
78 | 78 | self.show_images = True |
79 | 79 | self.languages = {} |
80 | 80 | self._lang_code_handler = languagenames.LanguageNames() |
81 | | self.catalogs = {} |
| 81 | self.catalogs_configuration = {} |
82 | 82 | self.catalog_history = [] |
83 | 83 | |
84 | 84 | if os.path.exists('/etc/get-books.cfg'): |
… |
… |
|
210 | 210 | |
211 | 211 | _SOURCES_CONFIG[section] = repo_config |
212 | 212 | |
| 213 | self.source = _SOURCES_CONFIG.keys()[0] |
| 214 | |
213 | 215 | logging.error('_SOURCES %s', _SOURCES) |
214 | 216 | logging.error('_SOURCES_CONFIG %s', _SOURCES_CONFIG) |
215 | 217 | |
… |
… |
|
230 | 232 | catalog_config['name'] = catalog |
231 | 233 | catalog_config['summary_field'] = \ |
232 | 234 | source_config['summary_field'] |
233 | | self.catalogs[catalog] = catalog_config |
| 235 | self.catalogs_configuration[catalog] = catalog_config |
| 236 | |
| 237 | |
| 238 | self.catalogs = {} |
| 239 | for catalog_key in self.catalogs_configuration: |
| 240 | catalog = self.catalogs_configuration[catalog_key] |
| 241 | if catalog['source'] == self.source: |
| 242 | self.catalogs[catalog_key]=catalog |
234 | 243 | |
235 | 244 | logging.error('languages %s', self.languages) |
236 | 245 | logging.error('catalogs %s', self.catalogs) |
… |
… |
|
498 | 507 | self.bt_move_up_catalog.hide_image() |
499 | 508 | self.treecol.set_widget(self.bt_move_up_catalog) |
500 | 509 | |
501 | | if len(self.catalogs) > 0: |
502 | | self.catalog_history.append({'title': _('Catalogs'), |
503 | | 'catalogs': self.catalogs}) |
504 | | self.categories = [] |
505 | | self.path_iter = {} |
506 | | for key in self.catalogs.keys(): |
507 | | self.categories.append({'text': key, 'dentro': []}) |
508 | | self.treemodel.clear() |
509 | | for p in self.categories: |
510 | | self.path_iter[p['text']] = self.treemodel.append([p['text']]) |
| 510 | self.load_source_catalogs() |
| 511 | |
511 | 512 | self.tree_scroller = gtk.ScrolledWindow(hadjustment=None, |
512 | 513 | vadjustment=None) |
513 | 514 | self.tree_scroller.set_policy(gtk.POLICY_NEVER, |
… |
… |
|
865 | 866 | else: |
866 | 867 | self.catalog_history.pop() |
867 | 868 | |
| 869 | def load_source_catalogs(self): |
| 870 | self.catalogs = {} |
| 871 | |
| 872 | for catalog_key in self.catalogs_configuration: |
| 873 | catalog = self.catalogs_configuration[catalog_key] |
| 874 | if catalog['source'] == self.source: |
| 875 | self.catalogs[catalog_key]=catalog |
| 876 | |
| 877 | if len(self.catalogs) > 0: |
| 878 | self.categories = [] |
| 879 | self.path_iter = {} |
| 880 | self.catalog_history = [] |
| 881 | self.catalog_history.append({'title': _('Catalogs'), |
| 882 | 'catalogs': self.catalogs}) |
| 883 | for key in self.catalogs.keys(): |
| 884 | self.categories.append({'text': key, 'dentro': []}) |
| 885 | self.treemodel.clear() |
| 886 | |
| 887 | for p in self.categories: |
| 888 | self.path_iter[p['text']] = self.treemodel.append([p['text']]) |
| 889 | |
| 890 | |
868 | 891 | def __source_changed_cb(self, widget): |
869 | 892 | search_terms = self.get_search_terms() |
870 | 893 | if search_terms == '': |
… |
… |
|
873 | 896 | self.find_books(search_terms) |
874 | 897 | # enable/disable catalogs button if configuration is available |
875 | 898 | self.source = self._books_toolbar.source_combo.props.value |
876 | | have_catalogs = False |
877 | | for catalog_name in self.catalogs.keys(): |
878 | | catalog_config = self.catalogs[catalog_name] |
879 | | if catalog_config['source'] == self.source: |
880 | | have_catalogs = True |
881 | | break |
882 | | if have_catalogs: |
| 899 | # Get catalogs for this source |
| 900 | self.load_source_catalogs() |
| 901 | |
| 902 | if len(self.catalogs)>0: |
883 | 903 | self.bt_catalogs.show() |
884 | 904 | self.bt_catalogs.set_active(True) |
885 | 905 | else: |
diff -u -r -N '-x=*.pyc/*.*~' /home/dcastelo/Downloads/GetBooks.activity/opds.py /home/dcastelo/Activities/GetBooks.activity/opds.py
old
|
new
|
|
38 | 38 | _REL_SUBSECTION = 'subsection' |
39 | 39 | _REL_OPDS_POPULAR = u'http://opds-spec.org/sort/popular' |
40 | 40 | _REL_OPDS_NEW = u'http://opds-spec.org/sort/new' |
| 41 | _REL_ALTERNATE = 'alternate' |
| 42 | _REL_CRAWLABLE = 'http://opds-spec.org/crawlable' |
41 | 43 | |
42 | 44 | gobject.threads_init() |
43 | 45 | |
… |
… |
|
91 | 93 | else: |
92 | 94 | feedobj = feedparser.parse(self.obj._uri) |
93 | 95 | |
| 96 | # Get catalog Type |
| 97 | CATALOG_TYPE = 'COMMON' |
| 98 | if 'links' in feedobj['feed']: |
| 99 | for link in feedobj['feed']['links']: |
| 100 | if link['rel'] == _REL_CRAWLABLE: |
| 101 | CATALOG_TYPE = 'CRAWLABLE' |
| 102 | break |
| 103 | |
94 | 104 | for entry in feedobj['entries']: |
95 | | if entry_type(entry) == 'BOOK': |
| 105 | if entry_type(entry) == 'BOOK' and CATALOG_TYPE is not 'CRAWLABLE': |
96 | 106 | self.obj._booklist.append(Book(self.obj._configuration, entry)) |
97 | | elif entry_type(entry) == 'CATALOG': |
| 107 | elif entry_type(entry) == 'CATALOG' or CATALOG_TYPE == 'CRAWLABLE': |
98 | 108 | self.obj._cataloglist.append( \ |
99 | 109 | Book(self.obj._configuration, entry)) |
100 | 110 | |
… |
… |
|
147 | 157 | elif link['rel'] in \ |
148 | 158 | [_REL_OPDS_POPULAR, _REL_OPDS_NEW, _REL_SUBSECTION]: |
149 | 159 | ret[link['type']] = link['href'] |
| 160 | elif link['rel'] == _REL_ALTERNATE: |
| 161 | ret[link['type']] = link['href'] |
150 | 162 | else: |
151 | 163 | pass |
152 | 164 | return ret |