/modules/lefigaro/module.py

https://github.com/laurentb/weboob · Python · 95 lines · 70 code · 8 blank · 17 comment · 1 complexity · 14da54c2f89b2ef600543727ec50aa14 MD5 · raw file

  1. # -*- coding: utf-8 -*-
  2. # Copyright(C) 2011 Julien Hebert
  3. #
  4. # This file is part of a weboob module.
  5. #
  6. # This weboob module is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU Affero General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This weboob module is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Affero General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Affero General Public License
  17. # along with this weboob module. If not, see <http://www.gnu.org/licenses/>.
  18. "backend for http://www.lefigaro.fr"
  19. from weboob.tools.newsfeed import Newsfeed
  20. from weboob.tools.backend import AbstractModule
  21. from weboob.tools.backend import BackendConfig
  22. from weboob.tools.value import Value
  23. from weboob.capabilities.messages import CapMessages, Thread
  24. from .browser import NewspaperFigaroBrowser
  25. from .tools import rssid
  26. class NewspaperFigaroModule(AbstractModule, CapMessages):
  27. MAINTAINER = u'Julien Hebert'
  28. EMAIL = 'juke@free.fr'
  29. VERSION = '2.1'
  30. LICENSE = 'AGPLv3+'
  31. STORAGE = {'seen': {}}
  32. NAME = 'lefigaro'
  33. DESCRIPTION = u'Le Figaro French newspaper website'
  34. BROWSER = NewspaperFigaroBrowser
  35. RSS_FEED = 'http://rss.lefigaro.fr/lefigaro/laune?format=xml'
  36. RSSID = staticmethod(rssid)
  37. RSSSIZE = 30
  38. PARENT = 'genericnewspaper'
  39. CONFIG = BackendConfig(Value('feed', label='RSS feed',
  40. choices={'actualites': u'actualites',
  41. 'flash-actu': u'flash-actu',
  42. 'politique': u'politique',
  43. 'international': u'international',
  44. 'actualite-france': u'actualite-france',
  45. 'hightech': u'hightech',
  46. 'sciences': u'sciences',
  47. 'sante': u'sante',
  48. 'lefigaromagazine': u'lefigaromagazine',
  49. 'photos': u'photos',
  50. 'economie': u'economie',
  51. 'societes': u'societes',
  52. 'medias': u'medias',
  53. 'immobilier': u'immobilier',
  54. 'assurance': u'assurance',
  55. 'retraite': u'retraite',
  56. 'placement': u'placement',
  57. 'impots': u'impots',
  58. 'conso': u'conso',
  59. 'emploi': u'emploi',
  60. 'culture': u'culture',
  61. 'cinema': u'cinema',
  62. 'musique': u'musique',
  63. 'livres': u'livres',
  64. 'theatre': u'theatre',
  65. 'lifestyle': u'lifestyle',
  66. 'automobile': u'automobile',
  67. 'gastronomie': u'gastronomie',
  68. 'horlogerie': u'horlogerie',
  69. 'mode-homme': u'mode-homme',
  70. 'sortir-paris': u'sortir-paris',
  71. 'vins': u'vins',
  72. 'voyages': u'voyages',
  73. 'sport': u'sport',
  74. 'football': u'football',
  75. 'rugby': u'rugby',
  76. 'tennis': u'tennis',
  77. 'cyclisme': u'cyclisme',
  78. 'sport-business': u'sport-business'}))
  79. def __init__(self, *args, **kwargs):
  80. super(self.__class__, self).__init__(*args, **kwargs)
  81. self.RSS_FEED = "http://www.lefigaro.fr/rss/figaro_%s.xml" % self.config['feed'].get()
  82. def iter_threads(self):
  83. for article in Newsfeed(self.RSS_FEED, self.RSSID).iter_entries():
  84. thread = Thread(article.id)
  85. thread.title = article.title
  86. thread.date = article.datetime
  87. yield(thread)