mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
PRS505/700: Put books in author/title dir structure and use USBMS style / tag paths.
This commit is contained in:
parent
7814dda6d8
commit
4c6599fd45
@ -77,7 +77,6 @@ class CYBOOKG3(USBMS):
|
|||||||
newpath = path
|
newpath = path
|
||||||
mdata = metadata.next()
|
mdata = metadata.next()
|
||||||
|
|
||||||
if self.SUPPORTS_SUB_DIRS:
|
|
||||||
if 'tags' in mdata.keys():
|
if 'tags' in mdata.keys():
|
||||||
for tag in mdata['tags']:
|
for tag in mdata['tags']:
|
||||||
if tag.startswith(_('News')):
|
if tag.startswith(_('News')):
|
||||||
|
@ -119,19 +119,44 @@ class PRS505(CLI, Device):
|
|||||||
paths, ctimes = [], []
|
paths, ctimes = [], []
|
||||||
|
|
||||||
names = iter(names)
|
names = iter(names)
|
||||||
|
metadata = iter(metadata)
|
||||||
for infile in files:
|
for infile in files:
|
||||||
close = False
|
close = False
|
||||||
if not hasattr(infile, 'read'):
|
if not hasattr(infile, 'read'):
|
||||||
infile, close = open(infile, 'rb'), True
|
infile, close = open(infile, 'rb'), True
|
||||||
infile.seek(0)
|
infile.seek(0)
|
||||||
name = names.next()
|
|
||||||
paths.append(os.path.join(path, name))
|
newpath = path
|
||||||
if not os.path.exists(os.path.dirname(paths[-1])):
|
mdata = metadata.next()
|
||||||
os.makedirs(os.path.dirname(paths[-1]))
|
|
||||||
|
if 'tags' in mdata.keys():
|
||||||
|
for tag in mdata['tags']:
|
||||||
|
if tag.startswith(_('News')):
|
||||||
|
newpath = os.path.join(newpath, 'news')
|
||||||
|
newpath = os.path.join(newpath, mdata.get('title', ''))
|
||||||
|
newpath = os.path.join(newpath, mdata.get('timestamp', ''))
|
||||||
|
elif tag.startswith('/'):
|
||||||
|
newpath = path
|
||||||
|
newpath += tag
|
||||||
|
newpath = os.path.normpath(newpath)
|
||||||
|
break
|
||||||
|
|
||||||
|
if newpath == path:
|
||||||
|
newpath = os.path.join(newpath, mdata.get('authors', _('Unknown')))
|
||||||
|
newpath = os.path.join(newpath, mdata.get('title', _('Unknown')))
|
||||||
|
|
||||||
|
if not os.path.exists(newpath):
|
||||||
|
os.makedirs(newpath)
|
||||||
|
|
||||||
|
filepath = os.path.join(newpath, names.next())
|
||||||
|
paths.append(filepath)
|
||||||
|
|
||||||
self.put_file(infile, paths[-1], replace_file=True)
|
self.put_file(infile, paths[-1], replace_file=True)
|
||||||
|
|
||||||
if close:
|
if close:
|
||||||
infile.close()
|
infile.close()
|
||||||
ctimes.append(os.path.getctime(paths[-1]))
|
ctimes.append(os.path.getctime(paths[-1]))
|
||||||
|
|
||||||
return zip(paths, sizes, ctimes, cycle([on_card]))
|
return zip(paths, sizes, ctimes, cycle([on_card]))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user