mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Changing locale in a multithreaded program is unsafe after startup
If you need to format french day/month names, simple use an array with predefined names and lookup by index. In any case, the fr locale may not actually be available on user systems.
This commit is contained in:
parent
7eb17c1cd5
commit
13f9c072d2
@ -2,14 +2,15 @@
|
|||||||
liberation.fr
|
liberation.fr
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import json, base64, time, locale
|
import base64
|
||||||
|
import json
|
||||||
from mechanize import Request
|
import time
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from urllib.parse import quote, urlparse, urlencode
|
from urllib.parse import quote, urlencode, urlparse
|
||||||
|
|
||||||
from calibre import browser
|
from calibre import browser
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
from mechanize import Request
|
||||||
|
|
||||||
|
|
||||||
def resize(x):
|
def resize(x):
|
||||||
@ -24,7 +25,6 @@ def json_to_html(raw):
|
|||||||
sub = '<p class="desc">' + data['subheadlines']['basic'] + '</p>'
|
sub = '<p class="desc">' + data['subheadlines']['basic'] + '</p>'
|
||||||
|
|
||||||
auth = '<p class="auth">{}</p>\n'
|
auth = '<p class="auth">{}</p>\n'
|
||||||
locale.setlocale(locale.LC_TIME, 'fr_FR.UTF-8')
|
|
||||||
dt = datetime.fromisoformat(data['last_updated_date'][:-1]) + timedelta(seconds=time.timezone)
|
dt = datetime.fromisoformat(data['last_updated_date'][:-1]) + timedelta(seconds=time.timezone)
|
||||||
dt = dt.strftime('%b %d, %Y, %H:%M')
|
dt = dt.strftime('%b %d, %Y, %H:%M')
|
||||||
a = [x['name'] for x in data['credits']['by']]
|
a = [x['name'] for x in data['credits']['by']]
|
||||||
@ -34,7 +34,7 @@ def json_to_html(raw):
|
|||||||
auth = auth.format(dt)
|
auth = auth.format(dt)
|
||||||
|
|
||||||
lede = ''
|
lede = ''
|
||||||
if data['promo_items']['basic'].get('type', '') == 'image':
|
if data['promo_items']['basic'].get('type', '') == 'image':
|
||||||
lede = '<br><img src="{}"><div class="figc">{}</div>\n'.format(
|
lede = '<br><img src="{}"><div class="figc">{}</div>\n'.format(
|
||||||
resize(data['promo_items']['basic']['resized_image_urls']),
|
resize(data['promo_items']['basic']['resized_image_urls']),
|
||||||
data['promo_items']['basic'].get('caption', '')
|
data['promo_items']['basic'].get('caption', '')
|
||||||
@ -107,7 +107,7 @@ class Liberation(BasicNewsRecipe):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def get_obfuscated_article(self, url):
|
def get_obfuscated_article(self, url):
|
||||||
slug = urlparse(url).path
|
slug = urlparse(url).path
|
||||||
br = browser()
|
br = browser()
|
||||||
b64 = base64.b64decode(self.key)
|
b64 = base64.b64decode(self.key)
|
||||||
query = {
|
query = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user