View Single Post
Old 01-06-2013, 11:43 AM   #1
johanp
Member
johanp began at the beginning.
 
Posts: 15
Karma: 10
Join Date: Jan 2010
Location: Stockholm, Sweden
Device: Kobo Glo, PocketBook Touch 622
Fetching Lenta.ru from python script

Hi,

I have a setup where I fetch news from a python script on my Linux server using cron. It works well apart from Lenta.ru for which the description string contains non-ascii characters. I get the "Failed to find builtin recipe: " error. I'm running Python 2.7.1. I copied the description string from the builtin_recipes.xml file. Script:

Code:
#!/usr/bin/python
# -*- coding: utf-8 -*-

import os, subprocess, tempfile

os.environ['DISPLAY'] = ':1'

recipes = [u'Lenta.ru: Новости' 'Dagens Nyheter', \
           'Svenska Dagbladet', 'BBC News', 'La Repubblica']

tmp_dir = tempfile.mkdtemp()
out_file = tmp_dir + "/news.epub"

for recipe in recipes:
    subprocess.call(["ebook-convert", recipe + ".recipe", out_file])
    subprocess.call(["calibredb", "add", out_file])

os.remove(out_file)
os.removedirs(tmp_dir)
Any clue how to make this work?
johanp is offline   Reply With Quote