Commit 20b7789b authored by Dmitry Shelepnev's avatar Dmitry Shelepnev
Browse files

resolve conflicts

parents b14e0ba9 42f47bb3
Loading
Loading
Loading
Loading
+5.46 KiB

File added.

No diff preview for this file type.

+5.67 KiB

File added.

No diff preview for this file type.

+9.36 KiB

File added.

No diff preview for this file type.

+25 −6
Original line number Diff line number Diff line
@@ -20,12 +20,19 @@ def Download(request, book_id, zip_flag):
        bookshelf.objects.get_or_create(user=request.user, book=book)

    full_path=os.path.join(settings.ROOT_LIB,book.path)
    
    if book.cat_type==opdsdb.CAT_INP:
        # Убираем из пути INPX файл
        inpx_path, zip_name = os.path.split(full_path)
        path, inpx_file = os.path.split(inpx_path)
        full_path = os.path.join(path,zip_name)
        
    if settings.TITLE_AS_FILENAME:
        transname=utils.translit(book.title+'.'+book.format)
    else:
        transname=utils.translit(book.filename)
        
    if zip_flag=='1':
    if zip_flag == 1:
        dlfilename=transname+'.zip'   
        content_type='application/zip' 
    else:    
@@ -53,7 +60,7 @@ def Download(request, book_id, zip_flag):
        book_size=os.path.getsize(file_path)
        fo=codecs.open(file_path, "rb")
        s=fo.read()
    elif book.cat_type==opdsdb.CAT_ZIP:
    elif book.cat_type in [opdsdb.CAT_ZIP, opdsdb.CAT_INP]:
        fz=codecs.open(full_path, "rb")
        z = zipfile.ZipFile(fz, 'r', allowZip64=True)
        book_size=z.getinfo(book.filename).file_size
@@ -83,15 +90,21 @@ def Cover(request, book_id):
    book = Book.objects.get(id=book_id)
    response = HttpResponse()
    c0=0
    if book.format=='fb2':
    full_path=os.path.join(settings.ROOT_LIB,book.path)
    if book.cat_type==opdsdb.CAT_INP:
        # Убираем из пути INPX файл
        inpx_path, zip_name = os.path.split(full_path)
        path, inpx_file = os.path.split(inpx_path)
        full_path = os.path.join(path,zip_name)   
         
    if book.format=='fb2':        
        fb2=fb2parse.fb2parser(1)
        if book.cat_type==opdsdb.CAT_NORMAL:
            file_path=os.path.join(full_path,book.filename)
            fo=codecs.open(file_path, "rb")
            fb2.parse(fo,0)
            fo.close()
        elif book.cat_type==opdsdb.CAT_ZIP:
        elif book.cat_type in [opdsdb.CAT_ZIP, opdsdb.CAT_INP]:
            fz=codecs.open(full_path, "rb")
            z = zipfile.ZipFile(fz, 'r', allowZip64=True)
            fo = z.open(book.filename)
@@ -132,6 +145,12 @@ def ConvertFB2(request, book_id, convert_type):
        bookshelf.objects.get_or_create(user=request.user, book=book)

    full_path=os.path.join(settings.ROOT_LIB,book.path)
    if book.cat_type==opdsdb.CAT_INP:
        # Убираем из пути INPX файл
        inpx_path, zip_name = os.path.split(full_path)
        path, inpx_file = os.path.split(inpx_path)
        full_path = os.path.join(path,zip_name)  
            
    if settings.TITLE_AS_FILENAME:
        transname=utils.translit(book.title+'.'+book.format)
    else:
@@ -151,7 +170,7 @@ def ConvertFB2(request, book_id, convert_type):
    if book.cat_type==opdsdb.CAT_NORMAL:
        tmp_fb2_path=None
        file_path=os.path.join(full_path, book.filename)
    elif book.cat_type==opdsdb.CAT_ZIP:
    elif book.cat_type in [opdsdb.CAT_ZIP, opdsdb.CAT_INP]:
        fz=codecs.open(full_path, "rb")
        z = zipfile.ZipFile(fz, 'r', allowZip64=True)
        z.extract(book.filename,settings.TEMP_DIR)
+2 −1
Original line number Diff line number Diff line
@@ -151,8 +151,9 @@ def findbook(name, path, setavail=0):

    return book


def addbook(name, path, cat, exten, title, annotation, docdate, lang, size=0, archive=0):
    book = Book.objects.create(filename=name,path=path,catalog=cat,filesize=size,format=exten[:8],
    book = Book.objects.create(filename=name,path=path,catalog=cat,filesize=size,format=exten.lower()[:8],
                title=title[:256],search_title=title.upper()[:256],annotation=annotation[:10000],docdate=docdate[:32],lang=lang[:16],
                cat_type=archive,avail=2, lang_code=getlangcode(title))
    return book
Loading