-
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathfix_ogvjs_dist.py
More file actions
executable file
·44 lines (33 loc) · 1.24 KB
/
fix_ogvjs_dist.py
File metadata and controls
executable file
·44 lines (33 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
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
"""quick script to fix videojs-ogvjs so that it triggers on webm mimetype"""
import logging
import pathlib
import sys
logging.basicConfig(format="%(levelname)s:%(message)s", level=logging.DEBUG)
logger = logging.getLogger(__name__)
def fix_source_dir(source_vendors_path: pathlib.Path | str):
"""update ogvjs plugin to trigger on webm mimetype"""
root = pathlib.Path(source_vendors_path)
logger.info("fixing videosjs-ogvjs.js")
plugin_path = root.joinpath("videojs-ogvjs.js")
with open(plugin_path) as fp:
content = fp.read()
content = content.replace(
"return type.indexOf('/ogg') !== -1 ? 'maybe' : '';",
"return (type.indexOf('/webm') !== -1 || type.indexOf('/ogg') !== -1)"
" ? 'maybe' : '';",
)
with open(plugin_path, "w") as fp:
fp.write(content)
logger.info("all done.")
def run(args: list[str] = sys.argv):
if len(args) < 2: # noqa: PLR2004
print(f"Usage: {args[0]} <source_vendors_path>") # noqa: T201
print( # noqa: T201
"\t<source_vendors_path>\tpath to your folder containing "
"ogvjs/videojs/videojs-ogvjs."
)
return 1
fix_source_dir(args[1])
return 0
if __name__ == "__main__":
sys.exit(run())