22import os
33from .logger import logger
44
5+ MEDIA_DIR = ""
6+ VIDEO_DIR = ""
7+ VIDEO_OUTPUT_DIR = ""
8+ TEX_DIR = ""
9+ TEXT_DIR = ""
10+ TEX_TEMPLATE = None
11+
12+ def initialize_directories (config ):
13+ global MEDIA_DIR
14+ global VIDEO_DIR
15+ global VIDEO_OUTPUT_DIR
16+ global TEX_DIR
17+ global TEXT_DIR
18+
19+ video_path_specified = config ["video_dir" ] or config ["video_output_dir" ]
20+
21+ if not (video_path_specified and config ["tex_dir" ]):
22+ if config ["media_dir" ]:
23+ MEDIA_DIR = config ["media_dir" ]
24+ else :
25+ MEDIA_DIR = os .path .join (
26+ os .path .expanduser ('~' ),
27+ "Dropbox (3Blue1Brown)/3Blue1Brown Team Folder"
28+ )
29+ if not os .path .isdir (MEDIA_DIR ):
30+ MEDIA_DIR = "./media"
31+ print (
32+ f"Media will be written to { MEDIA_DIR + os .sep } . You can change "
33+ "this behavior with the --media_dir flag."
34+ )
35+ else :
36+ if config ["media_dir" ]:
37+ print (
38+ "Ignoring --media_dir, since both --tex_dir and a video "
39+ "directory were both passed"
40+ )
41+
42+ TEX_DIR = config ["tex_dir" ] or os .path .join (MEDIA_DIR , "Tex" )
43+ TEXT_DIR = os .path .join (MEDIA_DIR , "texts" )
44+ if not video_path_specified :
45+ VIDEO_DIR = os .path .join (MEDIA_DIR , "videos" )
46+ VIDEO_OUTPUT_DIR = os .path .join (MEDIA_DIR , "videos" )
47+ elif config ["video_output_dir" ]:
48+ VIDEO_OUTPUT_DIR = config ["video_output_dir" ]
49+ else :
50+ VIDEO_DIR = config ["video_dir" ]
51+
52+ for folder in [VIDEO_DIR , VIDEO_OUTPUT_DIR , TEX_DIR , TEXT_DIR ]:
53+ if folder != "" and not os .path .exists (folder ):
54+ os .makedirs (folder )
55+
56+
557NOT_SETTING_FONT_MSG = '''
658You haven't set font.
759If you are not using English, this may cause text rendering problem.
@@ -20,19 +72,23 @@ class MyText(Text):
2072OBLIQUE = 'OBLIQUE'
2173BOLD = 'BOLD'
2274
23- TEX_USE_CTEX = False
24- TEX_TEXT_TO_REPLACE = "YourTextHere"
25- TEMPLATE_TEX_FILE = os .path .join (
26- os .path .dirname (os .path .realpath (__file__ )),
27- "tex_template.tex" if not TEX_USE_CTEX else "ctex_template.tex"
28- )
29- with open (TEMPLATE_TEX_FILE , "r" ) as infile :
30- TEMPLATE_TEXT_FILE_BODY = infile .read ()
31- TEMPLATE_TEX_FILE_BODY = TEMPLATE_TEXT_FILE_BODY .replace (
32- TEX_TEXT_TO_REPLACE ,
33- "\\ begin{align*}\n " + TEX_TEXT_TO_REPLACE + "\n \\ end{align*}" ,
34- )
35-
75+ HELP_MESSAGE = """
76+ Usage:
77+ python extract_scene.py <module> [<scene name>]
78+ -p preview in low quality
79+ -s show and save picture of last frame
80+ -w write result to file [this is default if nothing else is stated]
81+ -o <file_name> write to a different file_name
82+ -l use low quality
83+ -m use medium quality
84+ -a run and save every scene in the script, or all args for the given scene
85+ -q don't print progress
86+ -f when writing to a movie file, export the frames in png sequence
87+ -t use transperency when exporting images
88+ -n specify the number of the animation to start from
89+ -r specify a resolution
90+ -c specify a background color
91+ """
3692SCENE_NOT_FOUND_MESSAGE = """
3793 {} is not in the script
3894"""
0 commit comments