Example #1
0
 def is_updated(self, raw_str):
     if raw_str:
         # is it the same item?
         embedded_id = opf2id(raw_str)
         if embedded_id == str(self.thing.id):
             # Is it the same version (thus the same or updated)
             v = opf_version(raw_str)
             if v > self.version:
                 # Has the metadata changed (for the better)?
                 # @todo: this one is tricky
                 return v
     return False
Example #2
0
 def construct_library(self, c):
     library_path = os.path.join(LIBRARIES_PATH, str(c.id))
     for t in c.things:
         print "Adding", t.thing.title
         d = self.add_thing_folder_to_library(t.thing, str(c.id))
         #self.add_thing_to_library(t.thing, library_path)
     subprocess.call(['calibredb', 'add', '-r', '--library-path=%s' %
                      library_path, os.path.join('/tmp', str(c.id))])
     # now move covers
     for root, dirnames, filenames in os.walk(library_path):
         for filename in fnmatch.filter(filenames, '*.opf'):
             with open(os.path.join(root, filename), 'r') as f:
                 id = opf2id(f.read())
                 cover = os.path.join('/tmp', str(c.id), id, 'cover.jpg')
                 if os.path.exists(cover):
                     dest = os.path.join(root, 'cover.jpg')
                     print 'Moving ', cover, 'to', dest
                     shutil.move(cover, dest)
Example #3
0
 def construct_library(self, c):
     library_path = os.path.join(LIBRARIES_PATH, str(c.id))
     for t in c.things:
         print "Adding", t.thing.title
         d = self.add_thing_folder_to_library(t.thing, str(c.id))
         #self.add_thing_to_library(t.thing, library_path)
     subprocess.call([
         'calibredb', 'add', '-r',
         '--library-path=%s' % library_path,
         os.path.join('/tmp', str(c.id))
     ])
     # now move covers
     for root, dirnames, filenames in os.walk(library_path):
         for filename in fnmatch.filter(filenames, '*.opf'):
             with open(os.path.join(root, filename), 'r') as f:
                 id = opf2id(f.read())
                 cover = os.path.join('/tmp', str(c.id), id, 'cover.jpg')
                 if os.path.exists(cover):
                     dest = os.path.join(root, 'cover.jpg')
                     print 'Moving ', cover, 'to', dest
                     shutil.move(cover, dest)