plugin-jm-server 0.1.12__tar.gz → 0.1.14__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: plugin_jm_server
3
- Version: 0.1.12
3
+ Version: 0.1.14
4
4
  Summary: plugin_jm_server, a plugin for jmcomic that can be used to view comics in a web browser.
5
5
  Home-page: https://github.com/hect0x7/plugin-jm-server
6
6
  Author: hect0x7
@@ -0,0 +1,3 @@
1
+ __version__ = '0.1.14'
2
+
3
+ from .app import *
@@ -20,6 +20,7 @@ class JmServer:
20
20
  def __init__(self,
21
21
  default_path,
22
22
  password,
23
+ ip_whitelist=None,
23
24
  current_path=None,
24
25
  img_overwrite: Optional[dict] = None,
25
26
  **extra,
@@ -49,8 +50,13 @@ class JmServer:
49
50
  self.password = password
50
51
  self.file_manager = FileManager(default_path, current_path)
51
52
  self.extra = extra
53
+ self.ip_whitelist = ip_whitelist
52
54
 
53
55
  def verify(self):
56
+ ip_whitelist = self.ip_whitelist
57
+ if ip_whitelist is not None and request.remote_addr not in ip_whitelist:
58
+ abort(404)
59
+
54
60
  """
55
61
  验证登录状态
56
62
  """
@@ -22,12 +22,18 @@ class FileManager:
22
22
  def get_jm_view_images(self, path):
23
23
  images_data = []
24
24
 
25
+ give_up_sort = False
26
+
25
27
  for f in self.files_of_dir_safe(path):
26
28
  if not self.is_image_file(f):
27
29
  continue
28
30
  f = quote(f)
29
31
  name = common.of_file_name(f)
30
- index = int(name[:name.index('.')])
32
+ try:
33
+ index = int(name[:name.index('.')])
34
+ except ValueError:
35
+ give_up_sort = True
36
+ index = None
31
37
 
32
38
  images_data.append({
33
39
  'filename': name,
@@ -35,7 +41,8 @@ class FileManager:
35
41
  'index': index,
36
42
  })
37
43
 
38
- images_data.sort(key=lambda item: item['index'])
44
+ if give_up_sort is False:
45
+ images_data.sort(key=lambda item: item['index'])
39
46
 
40
47
  return images_data
41
48
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: plugin_jm_server
3
- Version: 0.1.12
3
+ Version: 0.1.14
4
4
  Summary: plugin_jm_server, a plugin for jmcomic that can be used to view comics in a web browser.
5
5
  Home-page: https://github.com/hect0x7/plugin-jm-server
6
6
  Author: hect0x7
@@ -1,3 +0,0 @@
1
- __version__ = '0.1.12'
2
-
3
- from .app import *