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
686da41675
@ -15,7 +15,7 @@ import re
|
|||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
from calibre.utils.magick import Image
|
from calibre.utils.magick import Image
|
||||||
|
|
||||||
class Microwave_and_RF(BasicNewsRecipe):
|
class Microwaves_and_RF(BasicNewsRecipe):
|
||||||
|
|
||||||
Convert_Grayscale = False # Convert images to gray scale or not
|
Convert_Grayscale = False # Convert images to gray scale or not
|
||||||
|
|
||||||
@ -25,9 +25,9 @@ class Microwave_and_RF(BasicNewsRecipe):
|
|||||||
# Add sections that want to be included from the magazine
|
# Add sections that want to be included from the magazine
|
||||||
include_sections = []
|
include_sections = []
|
||||||
|
|
||||||
title = u'Microwave and RF'
|
title = u'Microwaves and RF'
|
||||||
__author__ = 'kiavash'
|
__author__ = u'kiavash'
|
||||||
description = u'Microwave and RF Montly Magazine'
|
description = u'Microwaves and RF Montly Magazine'
|
||||||
publisher = 'Penton Media, Inc.'
|
publisher = 'Penton Media, Inc.'
|
||||||
publication_type = 'magazine'
|
publication_type = 'magazine'
|
||||||
site = 'http://mwrf.com'
|
site = 'http://mwrf.com'
|
||||||
@ -96,9 +96,16 @@ class Microwave_and_RF(BasicNewsRecipe):
|
|||||||
|
|
||||||
def parse_index(self):
|
def parse_index(self):
|
||||||
|
|
||||||
# Fetches the main page of Microwave and RF
|
# Fetches the main page of Microwaves and RF
|
||||||
soup = self.index_to_soup(self.site)
|
soup = self.index_to_soup(self.site)
|
||||||
|
|
||||||
|
# First page has the ad, Let's find the redirect address.
|
||||||
|
url = soup.find('span', attrs={'class':'commonCopy'}).find('a').get('href')
|
||||||
|
if url.startswith('/'):
|
||||||
|
url = self.site + url
|
||||||
|
|
||||||
|
soup = self.index_to_soup(url)
|
||||||
|
|
||||||
# Searches the site for Issue ID link then returns the href address
|
# Searches the site for Issue ID link then returns the href address
|
||||||
# pointing to the latest issue
|
# pointing to the latest issue
|
||||||
latest_issue = soup.find('a', attrs={'href':lambda x: x and 'IssueID' in x}).get('href')
|
latest_issue = soup.find('a', attrs={'href':lambda x: x and 'IssueID' in x}).get('href')
|
||||||
|
@ -81,7 +81,7 @@ class ANDROID(USBMS):
|
|||||||
0x4e11 : [0x0100, 0x226, 0x227],
|
0x4e11 : [0x0100, 0x226, 0x227],
|
||||||
0x4e12 : [0x0100, 0x226, 0x227],
|
0x4e12 : [0x0100, 0x226, 0x227],
|
||||||
0x4e21 : [0x0100, 0x226, 0x227, 0x231],
|
0x4e21 : [0x0100, 0x226, 0x227, 0x231],
|
||||||
0x4e22 : [0x0100, 0x226, 0x227],
|
0x4e22 : [0x0100, 0x226, 0x227, 0x231],
|
||||||
0xb058 : [0x0222, 0x226, 0x227],
|
0xb058 : [0x0222, 0x226, 0x227],
|
||||||
0x0ff9 : [0x0226],
|
0x0ff9 : [0x0226],
|
||||||
0xdddd : [0x216],
|
0xdddd : [0x216],
|
||||||
@ -194,7 +194,8 @@ class ANDROID(USBMS):
|
|||||||
'__UMS_COMPOSITE', 'SGH-I997_CARD', 'MB870', 'ALPANDIGITAL',
|
'__UMS_COMPOSITE', 'SGH-I997_CARD', 'MB870', 'ALPANDIGITAL',
|
||||||
'ANDROID_MID', 'P990_SD_CARD', '.K080', 'LTE_CARD', 'MB853',
|
'ANDROID_MID', 'P990_SD_CARD', '.K080', 'LTE_CARD', 'MB853',
|
||||||
'A1-07___C0541A4F', 'XT912', 'MB855', 'XT910', 'BOOK_A10_CARD',
|
'A1-07___C0541A4F', 'XT912', 'MB855', 'XT910', 'BOOK_A10_CARD',
|
||||||
'USB_2.0_DRIVER', 'I9100T', 'P999DW_SD_CARD', 'KTABLET_PC']
|
'USB_2.0_DRIVER', 'I9100T', 'P999DW_SD_CARD', 'KTABLET_PC',
|
||||||
|
'FILE-CD_GADGET']
|
||||||
|
|
||||||
OSX_MAIN_MEM = 'Android Device Main Memory'
|
OSX_MAIN_MEM = 'Android Device Main Memory'
|
||||||
|
|
||||||
|
@ -556,6 +556,7 @@ class Metadata(object):
|
|||||||
# Happens if x is not a text, is_multiple field
|
# Happens if x is not a text, is_multiple field
|
||||||
# on self
|
# on self
|
||||||
lstags = []
|
lstags = []
|
||||||
|
self_tags = []
|
||||||
ot, st = map(frozenset, (lotags, lstags))
|
ot, st = map(frozenset, (lotags, lstags))
|
||||||
for t in st.intersection(ot):
|
for t in st.intersection(ot):
|
||||||
sidx = lstags.index(t)
|
sidx = lstags.index(t)
|
||||||
|
@ -27,6 +27,7 @@ class EXTHHeader(object): # {{{
|
|||||||
self.has_fake_cover = True
|
self.has_fake_cover = True
|
||||||
self.start_offset = None
|
self.start_offset = None
|
||||||
left = self.num_items
|
left = self.num_items
|
||||||
|
self.kf8_header = None
|
||||||
|
|
||||||
while left > 0:
|
while left > 0:
|
||||||
left -= 1
|
left -= 1
|
||||||
@ -95,6 +96,8 @@ class EXTHHeader(object): # {{{
|
|||||||
pass # ASIN or UUID
|
pass # ASIN or UUID
|
||||||
elif id == 116:
|
elif id == 116:
|
||||||
self.start_offset, = struct.unpack(b'>L', content)
|
self.start_offset, = struct.unpack(b'>L', content)
|
||||||
|
elif id == 121:
|
||||||
|
self.kf8_header, = struct.unpack(b'>L', content)
|
||||||
#else:
|
#else:
|
||||||
# print 'unhandled metadata record', id, repr(content)
|
# print 'unhandled metadata record', id, repr(content)
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -105,29 +105,29 @@ class MobiReader(object):
|
|||||||
user_encoding, self.log, try_extra_data_fix=try_extra_data_fix)
|
user_encoding, self.log, try_extra_data_fix=try_extra_data_fix)
|
||||||
self.name = self.name.decode(self.book_header.codec, 'replace')
|
self.name = self.name.decode(self.book_header.codec, 'replace')
|
||||||
self.kf8_type = None
|
self.kf8_type = None
|
||||||
is_kf8 = self.book_header.mobi_version == 8
|
k8i = getattr(self.book_header.exth, 'kf8_header', None)
|
||||||
if is_kf8:
|
|
||||||
|
if self.book_header.mobi_version == 8:
|
||||||
self.kf8_type = 'standalone'
|
self.kf8_type = 'standalone'
|
||||||
else: # Check for joint mobi 6 and kf 8 file
|
elif k8i is not None: # Check for joint mobi 6 and kf 8 file
|
||||||
KF8_BOUNDARY = b'BOUNDARY'
|
try:
|
||||||
for i, x in enumerate(self.sections[:-1]):
|
raw = self.sections[k8i-1][0]
|
||||||
sec = x[0]
|
except:
|
||||||
if (len(sec) == len(KF8_BOUNDARY) and sec ==
|
raw = None
|
||||||
KF8_BOUNDARY):
|
if raw == b'BOUNDARY':
|
||||||
try:
|
try:
|
||||||
self.book_header = BookHeader(self.sections[i+1][0],
|
self.book_header = BookHeader(self.sections[k8i][0],
|
||||||
self.ident, user_encoding, self.log)
|
self.ident, user_encoding, self.log)
|
||||||
# The following are only correct in the Mobi 6
|
# The following are only correct in the Mobi 6
|
||||||
# header not the Mobi 8 header
|
# header not the Mobi 8 header
|
||||||
for x in ('first_image_index',):
|
for x in ('first_image_index',):
|
||||||
setattr(self.book_header, x, getattr(bh, x))
|
setattr(self.book_header, x, getattr(bh, x))
|
||||||
if hasattr(self.book_header, 'huff_offset'):
|
if hasattr(self.book_header, 'huff_offset'):
|
||||||
self.book_header.huff_offset += i + 1
|
self.book_header.huff_offset += k8i
|
||||||
self.kf8_type = 'joint'
|
self.kf8_type = 'joint'
|
||||||
self.kf8_boundary = i
|
self.kf8_boundary = k8i-1
|
||||||
except:
|
except:
|
||||||
self.book_header = bh
|
self.book_header = bh
|
||||||
break
|
|
||||||
|
|
||||||
def check_for_drm(self):
|
def check_for_drm(self):
|
||||||
if self.book_header.encryption_type != 0:
|
if self.book_header.encryption_type != 0:
|
||||||
|
@ -477,8 +477,9 @@ def read_font_record(data, extent=1040): # {{{
|
|||||||
return ans
|
return ans
|
||||||
|
|
||||||
ans['font_data'] = font_data
|
ans['font_data'] = font_data
|
||||||
ans['ext'] = ('ttf' if font_data[:4] in {b'\0\1\0\0', b'true', b'ttcf'}
|
sig = font_data[:4]
|
||||||
else 'dat')
|
ans['ext'] = ('ttf' if sig in {b'\0\1\0\0', b'true', b'ttcf'}
|
||||||
|
else 'otf' if sig == b'OTTO' else 'dat')
|
||||||
|
|
||||||
return ans
|
return ans
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -14,7 +14,7 @@ from PIL import Image
|
|||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
|
|
||||||
from calibre import browser, relpath, unicode_path
|
from calibre import browser, relpath, unicode_path
|
||||||
from calibre.constants import filesystem_encoding
|
from calibre.constants import filesystem_encoding, iswindows
|
||||||
from calibre.utils.filenames import ascii_filename
|
from calibre.utils.filenames import ascii_filename
|
||||||
from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag
|
from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag
|
||||||
from calibre.ebooks.chardet import xml_to_unicode
|
from calibre.ebooks.chardet import xml_to_unicode
|
||||||
@ -213,6 +213,8 @@ class RecursiveFetcher(object):
|
|||||||
is_local = 5
|
is_local = 5
|
||||||
if is_local > 0:
|
if is_local > 0:
|
||||||
url = url[is_local:]
|
url = url[is_local:]
|
||||||
|
if iswindows and url.startswith('/'):
|
||||||
|
url = url[1:]
|
||||||
with open(url, 'rb') as f:
|
with open(url, 'rb') as f:
|
||||||
data = response(f.read())
|
data = response(f.read())
|
||||||
data.newurl = 'file:'+url # This is what mechanize does for
|
data.newurl = 'file:'+url # This is what mechanize does for
|
||||||
|
Loading…
x
Reference in New Issue
Block a user