paste* backends: Accept an URL or an ID
Like most other backends, with the id2url decorator.
This commit is contained in:
parent
c7968faa20
commit
dc35df83ef
6 changed files with 69 additions and 39 deletions
|
|
@ -19,10 +19,12 @@
|
|||
|
||||
|
||||
from weboob.tools.browser import BaseBrowser, BrowserHTTPNotFound
|
||||
from weboob.tools.browser.decorators import id2url
|
||||
|
||||
from weboob.capabilities.paste import PasteNotFound
|
||||
|
||||
from .pages import PastePage, PostPage
|
||||
from .paste import PastebinPaste
|
||||
|
||||
import urllib
|
||||
import re
|
||||
|
|
@ -51,6 +53,11 @@ class PastebinBrowser(BaseBrowser):
|
|||
except BrowserHTTPNotFound:
|
||||
raise PasteNotFound()
|
||||
|
||||
@id2url(PastebinPaste.id2url)
|
||||
def get_paste(self, url):
|
||||
_id = re.match(self.PASTE_URL, url).groupdict()['id']
|
||||
return PastebinPaste(_id)
|
||||
|
||||
def get_contents(self, _id):
|
||||
"""
|
||||
Get the contents from the raw URL
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue