Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Simple OPDS
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
Simple OPDS
Commits
6bd4f35d
Commit
6bd4f35d
authored
Mar 3, 2017
by
Dmitry Shelepnev
Browse files
Options
Downloads
Patches
Plain Diff
Replace in code mime_detector.format to mime_detector.fmt
parent
c4666f55
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
book_tools/format/__init__.py
+4
-4
4 additions, 4 deletions
book_tools/format/__init__.py
opds_catalog/dl.py
+3
-3
3 additions, 3 deletions
opds_catalog/dl.py
opds_catalog/feeds.py
+3
-3
3 additions, 3 deletions
opds_catalog/feeds.py
with
10 additions
and
10 deletions
book_tools/format/__init__.py
+
4
−
4
View file @
6bd4f35d
...
@@ -15,9 +15,9 @@ from book_tools.format.mobi import Mobipocket
...
@@ -15,9 +15,9 @@ from book_tools.format.mobi import Mobipocket
from
constance
import
config
from
constance
import
config
class
_
_detector
:
class
mime
_detector
:
@staticmethod
@staticmethod
def
f
orma
t
(
fmt
):
def
f
m
t
(
fmt
):
if
fmt
.
lower
()
==
'
xml
'
:
if
fmt
.
lower
()
==
'
xml
'
:
return
Mimetype
.
XML
return
Mimetype
.
XML
elif
fmt
.
lower
()
==
'
fb2
'
:
elif
fmt
.
lower
()
==
'
fb2
'
:
...
@@ -44,11 +44,11 @@ class __detector:
...
@@ -44,11 +44,11 @@ class __detector:
@staticmethod
@staticmethod
def
file
(
filename
):
def
file
(
filename
):
(
n
,
e
)
=
os
.
path
.
splitext
(
filename
)
(
n
,
e
)
=
os
.
path
.
splitext
(
filename
)
return
forma
t
(
e
[
1
:])
return
mime_detector
.
fm
t
(
e
[
1
:])
def
detect_mime
(
file
,
original_filename
):
def
detect_mime
(
file
,
original_filename
):
FB2_ROOT
=
'
FictionBook
'
FB2_ROOT
=
'
FictionBook
'
mime
=
_
_detector
.
file
(
original_filename
)
mime
=
mime
_detector
.
file
(
original_filename
)
try
:
try
:
if
mime
==
Mimetype
.
XML
:
if
mime
==
Mimetype
.
XML
:
...
...
This diff is collapsed.
Click to expand it.
opds_catalog/dl.py
+
3
−
3
View file @
6bd4f35d
...
@@ -12,7 +12,7 @@ from opds_catalog.models import Book, bookshelf
...
@@ -12,7 +12,7 @@ from opds_catalog.models import Book, bookshelf
from
opds_catalog
import
settings
,
utils
,
opdsdb
,
fb2parse
from
opds_catalog
import
settings
,
utils
,
opdsdb
,
fb2parse
import
opds_catalog.zipf
as
zipfile
import
opds_catalog.zipf
as
zipfile
from
book_tools.format
import
create_bookfile
,
_
_detector
from
book_tools.format
import
create_bookfile
,
mime
_detector
from
book_tools.format.mimetype
import
Mimetype
from
book_tools.format.mimetype
import
Mimetype
from
constance
import
config
from
constance
import
config
...
@@ -45,7 +45,7 @@ def Download(request, book_id, zip_flag):
...
@@ -45,7 +45,7 @@ def Download(request, book_id, zip_flag):
content_type
=
Mimetype
.
FB2_ZIP
if
book
.
format
==
'
fb2
'
else
Mimetype
.
ZIP
content_type
=
Mimetype
.
FB2_ZIP
if
book
.
format
==
'
fb2
'
else
Mimetype
.
ZIP
else
:
else
:
dlfilename
=
transname
dlfilename
=
transname
content_type
=
_
_detector
.
f
orma
t
(
book
.
format
)
content_type
=
mime
_detector
.
f
m
t
(
book
.
format
)
response
=
HttpResponse
()
response
=
HttpResponse
()
response
[
"
Content-Type
"
]
=
'
%s; name=
"
%s
"'
%
(
content_type
,
dlfilename
)
response
[
"
Content-Type
"
]
=
'
%s; name=
"
%s
"'
%
(
content_type
,
dlfilename
)
...
@@ -240,7 +240,7 @@ def ConvertFB2(request, book_id, convert_type):
...
@@ -240,7 +240,7 @@ def ConvertFB2(request, book_id, convert_type):
converter_path
=
config
.
SOPDS_FB2TOEPUB
converter_path
=
config
.
SOPDS_FB2TOEPUB
elif
convert_type
==
'
mobi
'
:
elif
convert_type
==
'
mobi
'
:
converter_path
=
config
.
SOPDS_FB2TOMOBI
converter_path
=
config
.
SOPDS_FB2TOMOBI
content_type
=
_
_detector
.
f
orma
t
(
convert_type
)
content_type
=
mime
_detector
.
f
m
t
(
convert_type
)
if
book
.
cat_type
==
opdsdb
.
CAT_NORMAL
:
if
book
.
cat_type
==
opdsdb
.
CAT_NORMAL
:
tmp_fb2_path
=
None
tmp_fb2_path
=
None
...
...
This diff is collapsed.
Click to expand it.
opds_catalog/feeds.py
+
3
−
3
View file @
6bd4f35d
...
@@ -12,7 +12,7 @@ from opds_catalog import settings
...
@@ -12,7 +12,7 @@ from opds_catalog import settings
from
opds_catalog.middleware
import
BasicAuthMiddleware
from
opds_catalog.middleware
import
BasicAuthMiddleware
from
opds_catalog.opds_paginator
import
Paginator
as
OPDS_Paginator
from
opds_catalog.opds_paginator
import
Paginator
as
OPDS_Paginator
from
book_tools.format
import
__detector
as
detector
from
book_tools.format
import
mime_
detector
from
book_tools.format.mimetype
import
Mimetype
from
book_tools.format.mimetype
import
Mimetype
from
constance
import
config
from
constance
import
config
...
@@ -294,7 +294,7 @@ class CatalogsFeed(AuthFeed):
...
@@ -294,7 +294,7 @@ class CatalogsFeed(AuthFeed):
if
item
[
'
is_catalog
'
]:
if
item
[
'
is_catalog
'
]:
return
(
opdsEnclosure
(
reverse
(
"
opds_catalog:cat_tree
"
,
kwargs
=
{
"
cat_id
"
:
item
[
'
id
'
]}),
"
application/atom+xml;profile=opds-catalog;kind=navigation
"
,
"
subsection
"
),)
return
(
opdsEnclosure
(
reverse
(
"
opds_catalog:cat_tree
"
,
kwargs
=
{
"
cat_id
"
:
item
[
'
id
'
]}),
"
application/atom+xml;profile=opds-catalog;kind=navigation
"
,
"
subsection
"
),)
else
:
else
:
mime
=
detector
.
f
orma
t
(
item
[
'
format
'
])
mime
=
mime_
detector
.
f
m
t
(
item
[
'
format
'
])
enclosure
=
[
opdsEnclosure
(
reverse
(
"
opds_catalog:download
"
,
kwargs
=
{
"
book_id
"
:
item
[
'
id
'
],
"
zip_flag
"
:
0
}),
mime
,
"
http://opds-spec.org/acquisition/open-access
"
),]
enclosure
=
[
opdsEnclosure
(
reverse
(
"
opds_catalog:download
"
,
kwargs
=
{
"
book_id
"
:
item
[
'
id
'
],
"
zip_flag
"
:
0
}),
mime
,
"
http://opds-spec.org/acquisition/open-access
"
),]
if
not
item
[
'
format
'
]
in
settings
.
NOZIP_FORMATS
:
if
not
item
[
'
format
'
]
in
settings
.
NOZIP_FORMATS
:
mimezip
=
Mimetype
.
FB2_ZIP
if
mime
==
Mimetype
.
FB2
else
"
%s+zip
"
%
mime
mimezip
=
Mimetype
.
FB2_ZIP
if
mime
==
Mimetype
.
FB2
else
"
%s+zip
"
%
mime
...
@@ -541,7 +541,7 @@ class SearchBooksFeed(AuthFeed):
...
@@ -541,7 +541,7 @@ class SearchBooksFeed(AuthFeed):
return
item
[
'
registerdate
'
]
return
item
[
'
registerdate
'
]
def
item_enclosures
(
self
,
item
):
def
item_enclosures
(
self
,
item
):
mime
=
detector
.
f
orma
t
(
item
[
'
format
'
])
mime
=
mime_
detector
.
f
m
t
(
item
[
'
format
'
])
enclosure
=
[
enclosure
=
[
opdsEnclosure
(
reverse
(
"
opds_catalog:download
"
,
kwargs
=
{
"
book_id
"
:
item
[
'
id
'
],
"
zip_flag
"
:
0
}),
mime
,
"
http://opds-spec.org/acquisition/open-access
"
),
]
opdsEnclosure
(
reverse
(
"
opds_catalog:download
"
,
kwargs
=
{
"
book_id
"
:
item
[
'
id
'
],
"
zip_flag
"
:
0
}),
mime
,
"
http://opds-spec.org/acquisition/open-access
"
),
]
if
not
item
[
'
format
'
]
in
settings
.
NOZIP_FORMATS
:
if
not
item
[
'
format
'
]
in
settings
.
NOZIP_FORMATS
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment