fserver 0.1.10__tar.gz → 0.2__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.
- {fserver-0.1.10 → fserver-0.2}/LICENSE +21 -21
- {fserver-0.1.10 → fserver-0.2}/PKG-INFO +76 -73
- {fserver-0.1.10 → fserver-0.2}/README.md +61 -61
- {fserver-0.1.10 → fserver-0.2}/fserver/__init__.py +4 -4
- {fserver-0.1.10 → fserver-0.2}/fserver/app.py +5 -5
- {fserver-0.1.10 → fserver-0.2}/fserver/bean.py +55 -55
- {fserver-0.1.10 → fserver-0.2}/fserver/cmd.py +144 -144
- {fserver-0.1.10 → fserver-0.2}/fserver/conf.py +56 -56
- {fserver-0.1.10 → fserver-0.2}/fserver/fserver_app.py +251 -251
- {fserver-0.1.10 → fserver-0.2}/fserver/git.py +78 -78
- {fserver-0.1.10 → fserver-0.2}/fserver/git_app.py +78 -78
- {fserver-0.1.10 → fserver-0.2}/fserver/path_util.py +178 -178
- {fserver-0.1.10 → fserver-0.2}/fserver/permission.py +164 -164
- {fserver-0.1.10 → fserver-0.2}/fserver/static/DPlayer.min.css +3 -3
- {fserver-0.1.10 → fserver-0.2}/fserver/static/DPlayer.min.js +1 -1
- {fserver-0.1.10 → fserver-0.2}/fserver/static/dash.all.min.js +31 -31
- {fserver-0.1.10 → fserver-0.2}/fserver/static/flv.min.js +7 -7
- {fserver-0.1.10 → fserver-0.2}/fserver/static/hls.js@latest +2 -2
- fserver-0.2/fserver/static/plyr.min.css +7 -0
- fserver-0.2/fserver/static/plyr.polyfilled.min.js +2 -0
- fserver-0.2/fserver/templates/error.html +67 -0
- {fserver-0.1.10 → fserver-0.2}/fserver/templates/list.html +682 -399
- fserver-0.2/fserver/templates/string.html +177 -0
- fserver-0.2/fserver/templates/video.html +817 -0
- {fserver-0.1.10 → fserver-0.2}/fserver/util.py +99 -99
- {fserver-0.1.10 → fserver-0.2}/fserver.egg-info/PKG-INFO +76 -73
- {fserver-0.1.10 → fserver-0.2}/fserver.egg-info/SOURCES.txt +2 -0
- {fserver-0.1.10 → fserver-0.2}/setup.cfg +4 -4
- {fserver-0.1.10 → fserver-0.2}/setup.py +52 -52
- fserver-0.1.10/fserver/templates/error.html +0 -11
- fserver-0.1.10/fserver/templates/string.html +0 -11
- fserver-0.1.10/fserver/templates/video.html +0 -72
- {fserver-0.1.10 → fserver-0.2}/fserver.egg-info/dependency_links.txt +0 -0
- {fserver-0.1.10 → fserver-0.2}/fserver.egg-info/entry_points.txt +0 -0
- {fserver-0.1.10 → fserver-0.2}/fserver.egg-info/requires.txt +0 -0
- {fserver-0.1.10 → fserver-0.2}/fserver.egg-info/top_level.txt +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018 Nonu
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Nonu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,73 +1,76 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: fserver
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: File Sharing Server implemented with flask and gevent
|
|
5
|
-
Home-page: https://github.com/Carrotor116/fserver
|
|
6
|
-
Author: Nonu
|
|
7
|
-
Author-email: carrotor116@gmail.com
|
|
8
|
-
License: MIT
|
|
9
|
-
Description-Content-Type: text/markdown
|
|
10
|
-
License-File: LICENSE
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
-
|
|
46
|
-
|
|
47
|
-
--
|
|
48
|
-
--
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: fserver
|
|
3
|
+
Version: 0.2
|
|
4
|
+
Summary: File Sharing Server implemented with flask and gevent
|
|
5
|
+
Home-page: https://github.com/Carrotor116/fserver
|
|
6
|
+
Author: Nonu
|
|
7
|
+
Author-email: carrotor116@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: Flask>=1.1.2
|
|
12
|
+
Requires-Dist: Flask-HTTPAuth>=4.6.0
|
|
13
|
+
Requires-Dist: gevent>=20.6.2
|
|
14
|
+
|
|
15
|
+
# fserver
|
|
16
|
+
|
|
17
|
+
File Sharing Server implemented with flask and gevent
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Install or Upgrade
|
|
21
|
+
|
|
22
|
+
```shell
|
|
23
|
+
$ pip install fserver -U
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Usage
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
usage: fserver [-h] [-d] [-u] [-o] [-i IP] [-p PORT] [-r PATH] [-a PATH [PATH ...]] [-b PATH [PATH ...]] [-s STRING]
|
|
31
|
+
[-v] [-g] [--git_path GIT_PATH] [--username USERNAME] [--password PASSWORD]
|
|
32
|
+
|
|
33
|
+
optional arguments:
|
|
34
|
+
-h, --help show this help message and exit
|
|
35
|
+
-d, --debug run with debug mode
|
|
36
|
+
-u, --upload run with upload file function
|
|
37
|
+
-o, --override override mode for upload file
|
|
38
|
+
-i IP, --ip IP ip address for listening, default 0.0.0.0
|
|
39
|
+
-p PORT, --port PORT port for listening, default 2000
|
|
40
|
+
-r PATH, --root PATH root path for server, default current path
|
|
41
|
+
-a PATH [PATH ...], --allow PATH [PATH ...]
|
|
42
|
+
run with allow_list. Only [PATH ...] will be accessed
|
|
43
|
+
-b PATH [PATH ...], --block PATH [PATH ...]
|
|
44
|
+
run with block_list. [PATH ...] will not be accessed
|
|
45
|
+
-s STRING, --string STRING
|
|
46
|
+
share string only
|
|
47
|
+
-v, --version print version info
|
|
48
|
+
-g, --git open git http service for projections in root
|
|
49
|
+
--git_path GIT_PATH path for git executable file
|
|
50
|
+
--username USERNAME username for git authentication
|
|
51
|
+
--password PASSWORD password for git authentication
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Matching Rule
|
|
55
|
+
|
|
56
|
+
argument for `-a` and `-b` support wildcards "\*" and "\*\*".
|
|
57
|
+
|
|
58
|
+
"*" match multiple arbitrary character in a file name or directory name.
|
|
59
|
+
|
|
60
|
+
"**" match arbitrary multi-Level directories.
|
|
61
|
+
|
|
62
|
+
**example:**
|
|
63
|
+
|
|
64
|
+
| | */a2 | *1/a2 | b1/* | **/an | b1/** |
|
|
65
|
+
| -------- | ---- | ----- | ---- | ----- | ----- |
|
|
66
|
+
| a1/a2 | yes | yes | | | |
|
|
67
|
+
| a1/an | | | | yes | |
|
|
68
|
+
| a1/a2/an | | | | yes | |
|
|
69
|
+
| b1/a2 | yes | yes | yes | | yes |
|
|
70
|
+
| b1/a2/an | | | | yes | yes |
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
### License
|
|
76
|
+
[MIT](https://github.com/Carrotor116/fserver/blob/master/LICENSE)
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
# fserver
|
|
2
|
-
|
|
3
|
-
File Sharing Server implemented with flask and gevent
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
### Install or Upgrade
|
|
7
|
-
|
|
8
|
-
```shell
|
|
9
|
-
$ pip install fserver -U
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
### Usage
|
|
14
|
-
|
|
15
|
-
```text
|
|
16
|
-
usage: fserver [-h] [-d] [-u] [-o] [-i IP] [-p PORT] [-r PATH] [-a PATH [PATH ...]] [-b PATH [PATH ...]] [-s STRING]
|
|
17
|
-
[-v] [-g] [--git_path GIT_PATH] [--username USERNAME] [--password PASSWORD]
|
|
18
|
-
|
|
19
|
-
optional arguments:
|
|
20
|
-
-h, --help show this help message and exit
|
|
21
|
-
-d, --debug run with debug mode
|
|
22
|
-
-u, --upload run with upload file function
|
|
23
|
-
-o, --override override mode for upload file
|
|
24
|
-
-i IP, --ip IP ip address for listening, default 0.0.0.0
|
|
25
|
-
-p PORT, --port PORT port for listening, default 2000
|
|
26
|
-
-r PATH, --root PATH root path for server, default current path
|
|
27
|
-
-a PATH [PATH ...], --allow PATH [PATH ...]
|
|
28
|
-
run with allow_list. Only [PATH ...] will be accessed
|
|
29
|
-
-b PATH [PATH ...], --block PATH [PATH ...]
|
|
30
|
-
run with block_list. [PATH ...] will not be accessed
|
|
31
|
-
-s STRING, --string STRING
|
|
32
|
-
share string only
|
|
33
|
-
-v, --version print version info
|
|
34
|
-
-g, --git open git http service for projections in root
|
|
35
|
-
--git_path GIT_PATH path for git executable file
|
|
36
|
-
--username USERNAME username for git authentication
|
|
37
|
-
--password PASSWORD password for git authentication
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### Matching Rule
|
|
41
|
-
|
|
42
|
-
argument for `-a` and `-b` support wildcards "\*" and "\*\*".
|
|
43
|
-
|
|
44
|
-
"*" match multiple arbitrary character in a file name or directory name.
|
|
45
|
-
|
|
46
|
-
"**" match arbitrary multi-Level directories.
|
|
47
|
-
|
|
48
|
-
**example:**
|
|
49
|
-
|
|
50
|
-
| | */a2 | *1/a2 | b1/* | **/an | b1/** |
|
|
51
|
-
| -------- | ---- | ----- | ---- | ----- | ----- |
|
|
52
|
-
| a1/a2 | yes | yes | | | |
|
|
53
|
-
| a1/an | | | | yes | |
|
|
54
|
-
| a1/a2/an | | | | yes | |
|
|
55
|
-
| b1/a2 | yes | yes | yes | | yes |
|
|
56
|
-
| b1/a2/an | | | | yes | yes |
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
### License
|
|
1
|
+
# fserver
|
|
2
|
+
|
|
3
|
+
File Sharing Server implemented with flask and gevent
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Install or Upgrade
|
|
7
|
+
|
|
8
|
+
```shell
|
|
9
|
+
$ pip install fserver -U
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Usage
|
|
14
|
+
|
|
15
|
+
```text
|
|
16
|
+
usage: fserver [-h] [-d] [-u] [-o] [-i IP] [-p PORT] [-r PATH] [-a PATH [PATH ...]] [-b PATH [PATH ...]] [-s STRING]
|
|
17
|
+
[-v] [-g] [--git_path GIT_PATH] [--username USERNAME] [--password PASSWORD]
|
|
18
|
+
|
|
19
|
+
optional arguments:
|
|
20
|
+
-h, --help show this help message and exit
|
|
21
|
+
-d, --debug run with debug mode
|
|
22
|
+
-u, --upload run with upload file function
|
|
23
|
+
-o, --override override mode for upload file
|
|
24
|
+
-i IP, --ip IP ip address for listening, default 0.0.0.0
|
|
25
|
+
-p PORT, --port PORT port for listening, default 2000
|
|
26
|
+
-r PATH, --root PATH root path for server, default current path
|
|
27
|
+
-a PATH [PATH ...], --allow PATH [PATH ...]
|
|
28
|
+
run with allow_list. Only [PATH ...] will be accessed
|
|
29
|
+
-b PATH [PATH ...], --block PATH [PATH ...]
|
|
30
|
+
run with block_list. [PATH ...] will not be accessed
|
|
31
|
+
-s STRING, --string STRING
|
|
32
|
+
share string only
|
|
33
|
+
-v, --version print version info
|
|
34
|
+
-g, --git open git http service for projections in root
|
|
35
|
+
--git_path GIT_PATH path for git executable file
|
|
36
|
+
--username USERNAME username for git authentication
|
|
37
|
+
--password PASSWORD password for git authentication
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Matching Rule
|
|
41
|
+
|
|
42
|
+
argument for `-a` and `-b` support wildcards "\*" and "\*\*".
|
|
43
|
+
|
|
44
|
+
"*" match multiple arbitrary character in a file name or directory name.
|
|
45
|
+
|
|
46
|
+
"**" match arbitrary multi-Level directories.
|
|
47
|
+
|
|
48
|
+
**example:**
|
|
49
|
+
|
|
50
|
+
| | */a2 | *1/a2 | b1/* | **/an | b1/** |
|
|
51
|
+
| -------- | ---- | ----- | ---- | ----- | ----- |
|
|
52
|
+
| a1/a2 | yes | yes | | | |
|
|
53
|
+
| a1/an | | | | yes | |
|
|
54
|
+
| a1/a2/an | | | | yes | |
|
|
55
|
+
| b1/a2 | yes | yes | yes | | yes |
|
|
56
|
+
| b1/a2/an | | | | yes | yes |
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
### License
|
|
62
62
|
[MIT](LICENSE)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
|
-
from . import fserver_app
|
|
4
|
-
from . import git_app
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from . import fserver_app
|
|
4
|
+
from . import git_app
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
|
-
from flask import Flask
|
|
4
|
-
|
|
5
|
-
app = Flask(__name__, template_folder='templates')
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from flask import Flask
|
|
4
|
+
|
|
5
|
+
app = Flask(__name__, template_folder='templates')
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
|
-
class GetArg(object):
|
|
4
|
-
ARG_MODE = 'mode'
|
|
5
|
-
ARG_PLAY = 'play_type'
|
|
6
|
-
|
|
7
|
-
MODE_NORMAL = 'normal'
|
|
8
|
-
MODE_TXT = 'txt'
|
|
9
|
-
MODE_VIDEO = 'play'
|
|
10
|
-
MODE_DOWN = 'down'
|
|
11
|
-
MODES = (MODE_NORMAL, MODE_TXT, MODE_VIDEO, MODE_DOWN)
|
|
12
|
-
|
|
13
|
-
PLAY_AUTO = 'auto'
|
|
14
|
-
PLAY_MP4 = 'mp4'
|
|
15
|
-
PLAY_FLV = 'flv'
|
|
16
|
-
PLAY_HLS = 'hls'
|
|
17
|
-
PLAY_DASH = 'dash'
|
|
18
|
-
PLAYS = (PLAY_AUTO, PLAY_MP4, PLAY_FLV, PLAY_HLS, PLAY_DASH)
|
|
19
|
-
|
|
20
|
-
__slots__ = 'mode', 'play'
|
|
21
|
-
|
|
22
|
-
def __init__(self, request_arg=None):
|
|
23
|
-
self.mode = None
|
|
24
|
-
self.play = None
|
|
25
|
-
if request_arg is not None:
|
|
26
|
-
self.resolve_arg(request_arg)
|
|
27
|
-
|
|
28
|
-
def resolve_arg(self, request_arg):
|
|
29
|
-
self.mode = request_arg.get(self.ARG_MODE, default=None)
|
|
30
|
-
if self.mode is not None and self.mode not in self.MODES:
|
|
31
|
-
self.mode = self.MODE_NORMAL
|
|
32
|
-
|
|
33
|
-
self.play = request_arg.get(self.ARG_PLAY)
|
|
34
|
-
if self.play is not None and self.play not in self.PLAYS:
|
|
35
|
-
self.play = self.PLAY_AUTO
|
|
36
|
-
|
|
37
|
-
def format_for_url(self):
|
|
38
|
-
args = []
|
|
39
|
-
if self.mode in self.MODES:
|
|
40
|
-
args.append(self.ARG_MODE + '=' + self.mode)
|
|
41
|
-
if self.play in self.PLAYS:
|
|
42
|
-
args.append(self.ARG_PLAY + '=' + self.play)
|
|
43
|
-
|
|
44
|
-
if len(args) > 0:
|
|
45
|
-
return '?' + '&'.join(args)
|
|
46
|
-
else:
|
|
47
|
-
return ''
|
|
48
|
-
|
|
49
|
-
def to_dict(self):
|
|
50
|
-
res = {}
|
|
51
|
-
if self.mode is not None:
|
|
52
|
-
res[GetArg.ARG_MODE] = self.mode
|
|
53
|
-
if self.play is not None:
|
|
54
|
-
res[GetArg.ARG_PLAY] = self.play
|
|
55
|
-
return res
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
class GetArg(object):
|
|
4
|
+
ARG_MODE = 'mode'
|
|
5
|
+
ARG_PLAY = 'play_type'
|
|
6
|
+
|
|
7
|
+
MODE_NORMAL = 'normal'
|
|
8
|
+
MODE_TXT = 'txt'
|
|
9
|
+
MODE_VIDEO = 'play'
|
|
10
|
+
MODE_DOWN = 'down'
|
|
11
|
+
MODES = (MODE_NORMAL, MODE_TXT, MODE_VIDEO, MODE_DOWN)
|
|
12
|
+
|
|
13
|
+
PLAY_AUTO = 'auto'
|
|
14
|
+
PLAY_MP4 = 'mp4'
|
|
15
|
+
PLAY_FLV = 'flv'
|
|
16
|
+
PLAY_HLS = 'hls'
|
|
17
|
+
PLAY_DASH = 'dash'
|
|
18
|
+
PLAYS = (PLAY_AUTO, PLAY_MP4, PLAY_FLV, PLAY_HLS, PLAY_DASH)
|
|
19
|
+
|
|
20
|
+
__slots__ = 'mode', 'play'
|
|
21
|
+
|
|
22
|
+
def __init__(self, request_arg=None):
|
|
23
|
+
self.mode = None
|
|
24
|
+
self.play = None
|
|
25
|
+
if request_arg is not None:
|
|
26
|
+
self.resolve_arg(request_arg)
|
|
27
|
+
|
|
28
|
+
def resolve_arg(self, request_arg):
|
|
29
|
+
self.mode = request_arg.get(self.ARG_MODE, default=None)
|
|
30
|
+
if self.mode is not None and self.mode not in self.MODES:
|
|
31
|
+
self.mode = self.MODE_NORMAL
|
|
32
|
+
|
|
33
|
+
self.play = request_arg.get(self.ARG_PLAY)
|
|
34
|
+
if self.play is not None and self.play not in self.PLAYS:
|
|
35
|
+
self.play = self.PLAY_AUTO
|
|
36
|
+
|
|
37
|
+
def format_for_url(self):
|
|
38
|
+
args = []
|
|
39
|
+
if self.mode in self.MODES:
|
|
40
|
+
args.append(self.ARG_MODE + '=' + self.mode)
|
|
41
|
+
if self.play in self.PLAYS:
|
|
42
|
+
args.append(self.ARG_PLAY + '=' + self.play)
|
|
43
|
+
|
|
44
|
+
if len(args) > 0:
|
|
45
|
+
return '?' + '&'.join(args)
|
|
46
|
+
else:
|
|
47
|
+
return ''
|
|
48
|
+
|
|
49
|
+
def to_dict(self):
|
|
50
|
+
res = {}
|
|
51
|
+
if self.mode is not None:
|
|
52
|
+
res[GetArg.ARG_MODE] = self.mode
|
|
53
|
+
if self.play is not None:
|
|
54
|
+
res[GetArg.ARG_PLAY] = self.play
|
|
55
|
+
return res
|