mirror of
				https://github.com/kovidgoyal/calibre.git
				synced 2025-11-03 19:17:02 -05:00 
			
		
		
		
	Fix #3047 (Metadata on device, fall back to file name)
This commit is contained in:
		
						commit
						444f76fc25
					
				
							
								
								
									
										16
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								setup.py
									
									
									
									
									
								
							@ -60,17 +60,15 @@ if __name__ == '__main__':
 | 
			
		||||
    optional = []
 | 
			
		||||
    qmake = '/Volumes/sw/qt/bin/qmake' if isosx else 'qmake'
 | 
			
		||||
    qmake = os.environ.get('QMAKE', qmake)
 | 
			
		||||
    raw = subprocess.Popen([qmake, '-query'],
 | 
			
		||||
    def qmake_query(arg=''):
 | 
			
		||||
        return subprocess.Popen([qmake, '-query', arg],
 | 
			
		||||
            stdout=subprocess.PIPE).stdout.read()
 | 
			
		||||
    qt_inc = qt_lib = None
 | 
			
		||||
    for line in raw.splitlines():
 | 
			
		||||
        q, _, w = line.partition(':')
 | 
			
		||||
        if q == 'QT_INSTALL_HEADERS':
 | 
			
		||||
            qt_inc = w
 | 
			
		||||
        elif q == 'QT_INSTALL_LIBS':
 | 
			
		||||
            qt_lib = w
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    qt_inc = qmake_query('QT_INSTALL_HEADERS').splitlines()[0]
 | 
			
		||||
    qt_inc = qt_inc if qt_inc not in ('', '**Unknown**') and os.path.isdir(qt_inc) else None
 | 
			
		||||
    qt_lib = qmake_query('QT_INSTALL_LIBS').splitlines()[0]
 | 
			
		||||
    qt_lib = qt_lib if qt_lib not in ('', '**Unknown**') and os.path.isdir(qt_lib) else None
 | 
			
		||||
    
 | 
			
		||||
    if iswindows:
 | 
			
		||||
        optional.append(Extension('calibre.plugins.winutil',
 | 
			
		||||
                sources=['src/calibre/utils/windows/winutil.c'],
 | 
			
		||||
 | 
			
		||||
@ -34,7 +34,7 @@ class IREXDR1000(USBMS):
 | 
			
		||||
 | 
			
		||||
    MAIN_MEMORY_VOLUME_LABEL  = 'IRex Digital Reader 1000 Main Memory'
 | 
			
		||||
 | 
			
		||||
    EBOOK_DIR_MAIN = ''
 | 
			
		||||
    EBOOK_DIR_MAIN = 'ebooks'
 | 
			
		||||
    SUPPORTS_SUB_DIRS = True
 | 
			
		||||
 | 
			
		||||
    def delete_books(self, paths, end_session=True):
 | 
			
		||||
 | 
			
		||||
@ -8,6 +8,7 @@ for a particular device.
 | 
			
		||||
 | 
			
		||||
import os
 | 
			
		||||
import fnmatch
 | 
			
		||||
import re
 | 
			
		||||
import shutil
 | 
			
		||||
from itertools import cycle
 | 
			
		||||
 | 
			
		||||
@ -207,8 +208,9 @@ class USBMS(CLI, Device):
 | 
			
		||||
        if cls.settings().read_metadata or cls.MUST_READ_METADATA:
 | 
			
		||||
            mi = cls.metadata_from_path(path)
 | 
			
		||||
        else:
 | 
			
		||||
            from calibre.ebooks.metadata import MetaInformation
 | 
			
		||||
            mi = MetaInformation(os.path.basename(path))
 | 
			
		||||
            from calibre.ebooks.metadata.meta import metadata_from_filename
 | 
			
		||||
            mi = metadata_from_filename(os.path.basename(path),
 | 
			
		||||
                re.compile(r'^(?P<title>[ \S]+?)[ _]-[ _](?P<author>[ \S]+?)_+\d+'))
 | 
			
		||||
 | 
			
		||||
        authors = authors_to_string(mi.authors)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -94,7 +94,7 @@ def get_metadata(stream, stream_type='lrf', use_libprs_metadata=False):
 | 
			
		||||
        # The regex is meant to match the standard format filenames are written
 | 
			
		||||
        # in: title_-_author_number.extension
 | 
			
		||||
        base.smart_update(metadata_from_filename(name, re.compile(
 | 
			
		||||
                            r'^(?P<title>\S+?)_-_(?P<author>\S+?)_+\d+')))
 | 
			
		||||
                    r'^(?P<title>[ \S]+?)[ _]-[ _](?P<author>[ \S]+?)_+\d+')))
 | 
			
		||||
        if base.title:
 | 
			
		||||
            base.title = base.title.replace('_', ' ')
 | 
			
		||||
        if base.authors:
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user