mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Correctly remove "partner" query param and some more fail proof in "La Jornada (Mexico)" recipe.
The recipe stopped working since July 11th, 2015 because "partner" query param changed position.
This commit is contained in:
parent
b876c31ef5
commit
68662d65d6
@ -5,6 +5,8 @@ www.jornada.unam.mx
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
from urllib import urlencode
|
||||||
|
from urlparse import urlparse, urlunparse, parse_qs
|
||||||
from calibre import strftime
|
from calibre import strftime
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
@ -86,6 +88,14 @@ class LaJornada_mx(BasicNewsRecipe):
|
|||||||
return soup
|
return soup
|
||||||
|
|
||||||
def get_article_url(self, article):
|
def get_article_url(self, article):
|
||||||
|
# Get link to original article URL
|
||||||
rurl = article.get('guid', None)
|
rurl = article.get('guid', None)
|
||||||
return rurl.rpartition('&partner=')[0]
|
if not rurl:
|
||||||
|
# Use the "link" attribute as failover
|
||||||
|
return article.get('link', None)
|
||||||
|
# Remove "partner" query param
|
||||||
|
u = urlparse(rurl)
|
||||||
|
query = parse_qs(u.query)
|
||||||
|
query.pop('partner', None)
|
||||||
|
u = u._replace(query=urlencode(query, True))
|
||||||
|
return urlunparse(u)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user