mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from trunk
This commit is contained in:
commit
9777b01107
41
resources/recipes/gamespot.recipe
Normal file
41
resources/recipes/gamespot.recipe
Normal file
@ -0,0 +1,41 @@
|
||||
__license__ = 'GPL v3'
|
||||
__author__ = u'Marc T\xf6nsing'
|
||||
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
class GamespotCom(BasicNewsRecipe):
|
||||
|
||||
title = u'Gamespot.com Reviews'
|
||||
description = 'review articles from gamespot.com'
|
||||
language = 'en'
|
||||
__author__ = u'Marc T\xf6nsing'
|
||||
|
||||
oldest_article = 7
|
||||
max_articles_per_feed = 40
|
||||
remove_empty_feeds = True
|
||||
no_stylesheets = True
|
||||
no_javascript = True
|
||||
|
||||
feeds = [
|
||||
('PC Reviews', 'http://www.gamespot.com/rss/game_updates.php?type=5&platform=5'),
|
||||
('XBOX 360 Reviews', 'http://www.gamespot.com/rss/game_updates.php?type=5&platform=1029'),
|
||||
('Wii Reviews', 'http://www.gamespot.com/rss/game_updates.php?type=5&platform=1031'),
|
||||
('PlayStation 3 Reviews', 'http://www.gamespot.com/rss/game_updates.php?type=5&platform=1028'),
|
||||
('PlayStation 2 Reviews', 'http://www.gamespot.com/rss/game_updates.php?type=5&platform=7'),
|
||||
('PlayStation Portable Reviews', 'http://www.gamespot.com/rss/game_updates.php?type=5&platform=1024'),
|
||||
('Nintendo DS Reviews', 'http://www.gamespot.com/rss/game_updates.php?type=5&platform=1026'),
|
||||
('iPhone Reviews', 'http://www.gamespot.com/rss/game_updates.php?type=5&platform=1049'),
|
||||
]
|
||||
|
||||
remove_tags = [
|
||||
dict(name='div', attrs={'class':'top_bar'}),
|
||||
dict(name='div', attrs={'class':'video_embed'})
|
||||
]
|
||||
|
||||
def get_cover_url(self):
|
||||
return 'http://image.gamespotcdn.net/gamespot/shared/gs5/gslogo_bw.gif'
|
||||
|
||||
def get_article_url(self, article):
|
||||
return article.get('link') + '?print=1'
|
||||
|
||||
|
@ -282,15 +282,22 @@ class HTMLInput(InputFormatPlugin):
|
||||
basedir = os.getcwd()
|
||||
self.opts = opts
|
||||
|
||||
fname = None
|
||||
if hasattr(stream, 'name'):
|
||||
basedir = os.path.dirname(stream.name)
|
||||
fname = os.path.basename(stream.name)
|
||||
|
||||
if file_ext != 'opf':
|
||||
if opts.dont_package:
|
||||
raise ValueError('The --dont-package option is not supported for an HTML input file')
|
||||
from calibre.ebooks.metadata.html import get_metadata
|
||||
oeb = self.create_oebbook(stream.name, basedir, opts, log,
|
||||
get_metadata(stream))
|
||||
mi = get_metadata(stream)
|
||||
if fname:
|
||||
from calibre.ebooks.metadata.meta import metadata_from_filename
|
||||
fmi = metadata_from_filename(fname)
|
||||
fmi.smart_update(mi)
|
||||
mi = fmi
|
||||
oeb = self.create_oebbook(stream.name, basedir, opts, log, mi)
|
||||
return oeb
|
||||
|
||||
from calibre.ebooks.conversion.plumber import create_oebbook
|
||||
|
@ -12,7 +12,7 @@ import os, time, sys, shutil
|
||||
|
||||
from calibre.utils.ipc.job import ParallelJob
|
||||
from calibre.utils.ipc.server import Server
|
||||
from calibre.ptempfile import PersistentTemporaryDirectory
|
||||
from calibre.ptempfile import PersistentTemporaryDirectory, TemporaryDirectory
|
||||
from calibre import prints
|
||||
from calibre.constants import filesystem_encoding
|
||||
|
||||
@ -39,6 +39,10 @@ def serialize_metadata_for(formats, tdir, id_):
|
||||
f.write(cdata)
|
||||
|
||||
def read_metadata_(task, tdir, notification=lambda x,y:x):
|
||||
with TemporaryDirectory() as mdir:
|
||||
do_read_metadata(task, tdir, mdir, notification)
|
||||
|
||||
def do_read_metadata(task, tdir, mdir, notification):
|
||||
from calibre.customize.ui import run_plugins_on_import
|
||||
for x in task:
|
||||
try:
|
||||
@ -48,17 +52,28 @@ def read_metadata_(task, tdir, notification=lambda x,y:x):
|
||||
try:
|
||||
if isinstance(formats, basestring): formats = [formats]
|
||||
import_map = {}
|
||||
fmts = []
|
||||
fmts, metadata_fmts = [], []
|
||||
for format in formats:
|
||||
mfmt = format
|
||||
name, ext = os.path.splitext(os.path.basename(format))
|
||||
nfp = run_plugins_on_import(format)
|
||||
if not nfp or not os.access(nfp, os.R_OK):
|
||||
nfp = format
|
||||
nfp = os.path.abspath(nfp)
|
||||
if not nfp or nfp == format or not os.access(nfp, os.R_OK):
|
||||
nfp = None
|
||||
else:
|
||||
# Ensure that the filename is preserved so that
|
||||
# reading metadata from filename is not broken
|
||||
nfp = os.path.abspath(nfp)
|
||||
nfext = os.path.splitext(nfp)[1]
|
||||
mfmt = os.path.join(mdir, name + nfext)
|
||||
shutil.copyfile(nfp, mfmt)
|
||||
metadata_fmts.append(mfmt)
|
||||
fmts.append(nfp)
|
||||
|
||||
serialize_metadata_for(fmts, tdir, id_)
|
||||
serialize_metadata_for(metadata_fmts, tdir, id_)
|
||||
|
||||
for format, nfp in zip(formats, fmts):
|
||||
if not nfp:
|
||||
continue
|
||||
if isinstance(nfp, unicode):
|
||||
nfp.encode(filesystem_encoding)
|
||||
x = lambda j : os.path.abspath(os.path.normpath(os.path.normcase(j)))
|
||||
@ -68,7 +83,6 @@ def read_metadata_(task, tdir, notification=lambda x,y:x):
|
||||
dest = os.path.join(tdir, '%s.%s'%(id_, nfmt))
|
||||
shutil.copyfile(nfp, dest)
|
||||
import_map[fmt] = dest
|
||||
os.remove(nfp)
|
||||
if import_map:
|
||||
with open(os.path.join(tdir, str(id_)+'.import'), 'wb') as f:
|
||||
for fmt, nfp in import_map.items():
|
||||
|
@ -571,6 +571,10 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
||||
self.initalize_authors()
|
||||
self.initialize_series()
|
||||
self.initialize_publisher()
|
||||
for x in ('authors', 'publisher', 'series'):
|
||||
x = getattr(self, x)
|
||||
x.setSizeAdjustPolicy(x.AdjustToMinimumContentsLengthWithIcon)
|
||||
x.setMinimumContentsLength(25)
|
||||
|
||||
def initalize_authors(self):
|
||||
all_authors = self.db.all_authors()
|
||||
|
Loading…
x
Reference in New Issue
Block a user