def getComicMetadata(self, path): ca = ComicArchive( path, default_image_path=AppFolders.missingPath("page.png")) if ca.seemsToBeAComicArchive(): if ca.hasMetadata(MetaDataStyle.CIX): style = MetaDataStyle.CIX elif ca.hasMetadata(MetaDataStyle.CBI): style = MetaDataStyle.CBI elif ca.hasMetadata(MetaDataStyle.COMET): style = MetaDataStyle.COMET elif ca.hasMetadata(MetaDataStyle.CBW): style = MetaDataStyle.CBW else: logging.warning(u"Library: File Has No ComicMeta Data") if ca.hasMetadata(MetaDataStyle.CALIBRE): style = MetaDataStyle.CALIBRE elif ca.hasMetadata(MetaDataStyle.EPUB): style = MetaDataStyle.EPUB else: style = None if style is not None: md = ca.readMetadata(style) if md.isEmpty: md = ca.metadataFromFilename() else: # No metadata in comic. make some guesses from the filename md = ca.metadataFromFilename() # patch version 2 if (md.title is None or md.title == "") and md.issue is None and not md.series is None: md.title = md.series md.series = None md.fingerprint = ca.fingerprint() md.path = ca.path md.page_count = ca.page_count md.mod_ts = datetime.utcfromtimestamp(getmtime(ca.path)) md.filesize = os.path.getsize(md.path) md.hash = "" #thumbnail generation image_data = ca.getPage(0, AppFolders.missingPath("cover.png")) #now resize it thumb = StringIO.StringIO() try: utils.resize(image_data, (400, 400), thumb) md.thumbnail = thumb.getvalue() except: md.thumbnail = None return md return None
def getComicMetadata(self, path): ca = ComicArchive(path, default_image_path=AppFolders.missingPath("page.png")) if ca.seemsToBeAComicArchive(): if ca.hasMetadata( MetaDataStyle.CIX ): style = MetaDataStyle.CIX elif ca.hasMetadata( MetaDataStyle.CBI ): style = MetaDataStyle.CBI elif ca.hasMetadata( MetaDataStyle.COMET ): style = MetaDataStyle.COMET elif ca.hasMetadata( MetaDataStyle.CBW ): style = MetaDataStyle.CBW else: logging.warning(u"Library: File Has No ComicMeta Data") if ca.hasMetadata( MetaDataStyle.CALIBRE ): style = MetaDataStyle.CALIBRE elif ca.hasMetadata( MetaDataStyle.EPUB ): style = MetaDataStyle.EPUB else: style = None if style is not None: md = ca.readMetadata(style) if md.isEmpty: md = ca.metadataFromFilename() else: # No metadata in comic. make some guesses from the filename md = ca.metadataFromFilename() # patch version 2 if (md.title is None or md.title == "") and md.issue is None and not md.series is None: md.title = md.series md.series = None md.fingerprint = ca.fingerprint() md.path = ca.path md.page_count = ca.page_count md.mod_ts = datetime.utcfromtimestamp(getmtime(ca.path)) md.filesize = os.path.getsize(md.path) md.hash = "" #thumbnail generation image_data = ca.getPage(0, AppFolders.missingPath("cover.png")) #now resize it thumb = StringIO.StringIO() try: utils.resize(image_data, (400, 400), thumb) md.thumbnail = thumb.getvalue() except: md.thumbnail = None return md return None
def getComicMetadata(self, path): ca = ComicArchive( path, default_image_path=AppFolders.missingPath("page.png")) if ca.seemsToBeAComicArchive(): if ca.hasMetadata(MetaDataStyle.CIX): style = MetaDataStyle.CIX elif ca.hasMetadata(MetaDataStyle.CBI): style = MetaDataStyle.CBI elif ca.hasMetadata(MetaDataStyle.COMET): style = MetaDataStyle.COMET elif ca.hasMetadata(MetaDataStyle.CBW): style = MetaDataStyle.CBW else: logging.warning(u"Library: File Has No ComicMeta Data") if ca.hasMetadata(MetaDataStyle.CALIBRE): style = MetaDataStyle.CALIBRE elif ca.hasMetadata(MetaDataStyle.EPUB): style = MetaDataStyle.EPUB else: style = None if style is not None: md = ca.readMetadata(style) if md.isEmpty: md = ca.metadataFromFilename() else: # No metadata in comic. make some guesses from the filename md = ca.metadataFromFilename() # patch version 2 if (md.title is None or md.title == "") and md.issue is None and not md.series is None: md.title = md.series md.series = None md.fingerprint = ca.fingerprint() md.path = ca.path md.page_count = ca.page_count md.mod_ts = datetime.utcfromtimestamp(getmtime(ca.path)) md.filesize = os.path.getsize(md.path) md.hash = "" #thumbnail generation image_data = ca.getPage(0, AppFolders.missingPath("cover.png")) #now resize it thumb = StringIO.StringIO() #Lets right thumbs to files. large libraries cause the database to bloat try: utils.resize(image_data, (400, 400), thumb) filename = md.fingerprint + ".png" foldername = filename[0] thumbSubFolder = AppFolders.appThumbFolder(foldername) if not os.path.exists(thumbSubFolder): os.makedirs(thumbSubFolder) folderpath = AppFolders.appThumbPath(foldername, filename) with open(folderpath, 'wb') as f: f.write(thumb.getvalue()) print("Extracted thumb: " + filename) except: print("Thumbnail extraction failed") # print md return md return None