finaly handle BrowserHTTPNotFound in backend browsers

This commit is contained in:
Julien Veyssier 2013-03-17 21:54:08 +01:00
commit 8d49950813
15 changed files with 78 additions and 50 deletions

View file

@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.browser import BaseBrowser
from weboob.tools.browser import BaseBrowser, BrowserHTTPNotFound
from .pages import RecipePage, ResultsPage
@ -42,6 +42,9 @@ class SevenFiftyGramsBrowser(BaseBrowser):
return self.page.iter_recipes()
def get_recipe(self, id):
self.location('http://www.750g.com/fiche_de_cuisine_complete.htm?recettes_id=%s' % id)
try:
self.location('http://www.750g.com/fiche_de_cuisine_complete.htm?recettes_id=%s' % id)
except BrowserHTTPNotFound:
return
if self.is_on_page(RecipePage):
return self.page.get_recipe(id)

View file

@ -48,5 +48,5 @@ class AttilasubBrowser(BaseBrowser):
self.location('http://davidbillemont3.free.fr/%s' % url_end)
except BrowserHTTPNotFound:
return
assert self.is_on_page(SubtitlesPage)
return self.page.get_subtitle(id)
if self.is_on_page(SubtitlesPage):
return self.page.get_subtitle(id)

View file

@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.browser import BaseBrowser
from weboob.tools.browser import BaseBrowser, BrowserHTTPNotFound
from .pages import TorrentsPage, TorrentPage
@ -42,6 +42,9 @@ class BtmonBrowser(BaseBrowser):
return self.page.iter_torrents()
def get_torrent(self, id):
self.location('http://www.btmon.com/%s.html' % id)
try:
self.location('http://www.btmon.com/%s.html' % id)
except BrowserHTTPNotFound:
return
if self.is_on_page(TorrentPage):
return self.page.get_torrent()

View file

@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.browser import BaseBrowser
from weboob.tools.browser import BaseBrowser, BrowserHTTPNotFound
from .pages import RecipePage, ResultsPage
@ -43,6 +43,9 @@ class CuisineazBrowser(BaseBrowser):
return self.page.iter_recipes()
def get_recipe(self, id):
self.location('http://www.cuisineaz.com/recettes/%s.aspx' % id)
try:
self.location('http://www.cuisineaz.com/recettes/%s.aspx' % id)
except BrowserHTTPNotFound:
return
if self.is_on_page(RecipePage):
return self.page.get_recipe(id)

View file

@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.browser import BaseBrowser
from weboob.tools.browser import BaseBrowser, BrowserHTTPNotFound
from .pages.torrents import TorrentsPage, TorrentPage
@ -45,6 +45,9 @@ class IsohuntBrowser(BaseBrowser):
return self.page.iter_torrents()
def get_torrent(self, id):
self.location('https://isohunt.com/torrent_details/%s/?tab=summary' % id)
try:
self.location('https://isohunt.com/torrent_details/%s/?tab=summary' % id)
except BrowserHTTPNotFound:
return
if self.is_on_page(TorrentPage):
return self.page.get_torrent(id)

View file

@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.browser import BaseBrowser
from weboob.tools.browser import BaseBrowser, BrowserHTTPNotFound
from .pages import TorrentsPage, TorrentPage
@ -45,6 +45,9 @@ class KickassBrowser(BaseBrowser):
return self.page.iter_torrents()
def get_torrent(self, id):
self.location('http://kat.ph/%s.html' % id)
assert self.is_on_page(TorrentPage)
return self.page.get_torrent(id)
try:
self.location('http://kat.ph/%s.html' % id)
except BrowserHTTPNotFound:
return
if self.is_on_page(TorrentPage):
return self.page.get_torrent(id)

View file

@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.browser import BaseBrowser
from weboob.tools.browser import BaseBrowser, BrowserHTTPNotFound
from .pages import RecipePage, ResultsPage
@ -42,6 +42,9 @@ class MarmitonBrowser(BaseBrowser):
return self.page.iter_recipes()
def get_recipe(self, id):
self.location('http://www.marmiton.org/recettes/recette_%s.aspx' % id)
try:
self.location('http://www.marmiton.org/recettes/recette_%s.aspx' % id)
except BrowserHTTPNotFound:
return
if self.is_on_page(RecipePage):
return self.page.get_recipe(id)

View file

@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.browser import BaseBrowser
from weboob.tools.browser import BaseBrowser, BrowserHTTPNotFound
from weboob.applications.suboob.suboob import LANGUAGE_CONV
from .pages import SubtitlesPage, SearchPage, SubtitlePage
@ -47,6 +47,9 @@ class OpensubtitlesBrowser(BaseBrowser):
return self.page.iter_subtitles()
def get_subtitle(self, id):
self.location('http://www.opensubtitles.org/subtitles/%s' % id)
assert self.is_on_page(SubtitlePage)
return self.page.get_subtitle()
try:
self.location('http://www.opensubtitles.org/subtitles/%s' % id)
except BrowserHTTPNotFound:
return
if self.is_on_page(SubtitlePage):
return self.page.get_subtitle()

View file

@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.browser import BaseBrowser
from weboob.tools.browser import BaseBrowser, BrowserHTTPNotFound
from .pages import SongResultsPage, SonglyricsPage, ArtistResultsPage, ArtistSongsPage
@ -50,6 +50,9 @@ class ParolesmaniaBrowser(BaseBrowser):
def get_lyrics(self, id):
ids = id.split('|')
self.location('http://www.parolesmania.com/paroles_%s/paroles_%s.html' % (ids[0], ids[1]))
assert self.is_on_page(SonglyricsPage)
return self.page.get_lyrics(id)
try:
self.location('http://www.parolesmania.com/paroles_%s/paroles_%s.html' % (ids[0], ids[1]))
except BrowserHTTPNotFound:
return
if self.is_on_page(SonglyricsPage):
return self.page.get_lyrics(id)

View file

@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.browser import BaseBrowser
from weboob.tools.browser import BaseBrowser, BrowserHTTPNotFound
from .pages import SongResultsPage, SonglyricsPage, ArtistResultsPage, ArtistSongsPage, HomePage
@ -45,6 +45,9 @@ class ParolesmusiqueBrowser(BaseBrowser):
return self.page.iter_lyrics(criteria, pattern)
def get_lyrics(self, id):
self.location('http://www.paroles-musique.com/paroles-%s' % id)
assert self.is_on_page(SonglyricsPage)
return self.page.get_lyrics(id)
try:
self.location('http://www.paroles-musique.com/paroles-%s' % id)
except BrowserHTTPNotFound:
return
if self.is_on_page(SonglyricsPage):
return self.page.get_lyrics(id)

View file

@ -20,7 +20,7 @@
import urllib
from weboob.tools.browser import BaseBrowser
from weboob.tools.browser import BaseBrowser, BrowserHTTPNotFound
from .pages.index import IndexPage
from .pages.torrents import TorrentsPage, TorrentPage
@ -49,6 +49,9 @@ class PiratebayBrowser(BaseBrowser):
return self.page.iter_torrents()
def get_torrent(self, id):
self.location('https://thepiratebay.se/torrent/%s/' % id)
assert self.is_on_page(TorrentPage)
return self.page.get_torrent(id)
try:
self.location('https://thepiratebay.se/torrent/%s/' % id)
except BrowserHTTPNotFound:
return
if self.is_on_page(TorrentPage):
return self.page.get_torrent(id)

View file

@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.browser import BaseBrowser
from weboob.tools.browser import BaseBrowser, BrowserHTTPNotFound
from .pages import SongResultsPage, SonglyricsPage, ArtistResultsPage, ArtistSongsPage
@ -48,6 +48,9 @@ class SeeklyricsBrowser(BaseBrowser):
return self.page.iter_lyrics()
def get_lyrics(self, id):
self.location('http://www.seeklyrics.com/lyrics/%s.html' % id)
assert self.is_on_page(SonglyricsPage)
return self.page.get_lyrics(id)
try:
self.location('http://www.seeklyrics.com/lyrics/%s.html' % id)
except BrowserHTTPNotFound:
return
if self.is_on_page(SonglyricsPage):
return self.page.get_lyrics(id)

View file

@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.browser import BaseBrowser
from weboob.tools.browser import BaseBrowser, BrowserHTTPNotFound
from .pages import SeriePage, SearchPage, SeasonPage, HomePage
@ -48,6 +48,9 @@ class TvsubtitlesBrowser(BaseBrowser):
return self.page.iter_subtitles(language, pattern)
def get_subtitle(self, id):
self.location('http://www.tvsubtitles.net/subtitle-%s.html' % id)
assert self.is_on_page(SeasonPage)
return self.page.get_subtitle()
try:
self.location('http://www.tvsubtitles.net/subtitle-%s.html' % id)
except BrowserHTTPNotFound:
return
if self.is_on_page(SeasonPage):
return self.page.get_subtitle()