-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
yapo.py
81 lines (68 loc) · 2.88 KB
/
yapo.py
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
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
74
75
76
77
78
79
80
81
#!/usr/bin/env python
import sys
import os
import shutil
from configuration import Config, Constants
from utils import dbcheck
from utils.printing import Logger
from utils import scenerenamer
log = Logger()
if Config().tpdb_apikey == "":
Config().tpdb_apikey = ""
Config().save()
#if os.path.exists(os.path.join(self.root_path,))
sitemediaold = os.path.join(Config().site_path, Constants().site_media_subdir)
if os.path.exists(sitemediaold): #)(Config().site_media_path):
log.sinfo(f"Media dir is currently {sitemediaold} (old configuration)")
newmedia = os.path.join(Config().root_path,Config().data_path,Constants().site_media_subdir)
newmedianosub = os.path.join(Config().root_path,Config().data_path)
if not os.path.exists(newmedia):
log.info(f'Media moves to {newmedia}...')
print(f"Source: {sitemediaold}")
print(f"Destination: {newmedianosub}")
try:
shutil.move(sitemediaold, newmedianosub)
except OSError as exp:
log.error(f"Error when moving media: {exp}")
print("Please move the media directory (within /videos) yourself to the /data directory,"
"then restart YAPO.")
Config().site_media_path = newmedia
Config().save()
sys.exit(0)
Config().site_media_path = newmedia
Config().save()
print(f"Configuration saved...")
else:
log.error('New media location {newmedia} already exists! Move the files manually.')
if not os.path.exists(Config().config_path):
os.makedirs(Config().config_path)
if not os.path.isfile(Config().configfile_path):
Config().save()
if not os.path.exists(Config().temp_path):
os.makedirs(Config().temp_path)
if not os.path.exists(os.path.join(Config().site_media_path,"logos")):
os.makedirs(os.path.join(Config().site_media_path,"logos"))
if not os.path.exists(os.path.join(Config().site_media_path,"scenes")):
os.makedirs(os.path.join(Config().site_media_path,"scenes"))
if not os.path.exists(os.path.join(Config().site_media_path,"tags")):
os.makedirs(os.path.join(Config().site_media_path,"tags"))
if not os.path.exists(os.path.join(Config().site_media_path,"websites")):
os.makedirs(os.path.join(Config().site_media_path,"websites"))
if not os.path.exists(Config().database_dir):
os.makedirs(Config().database_dir)
if "no-migration" not in str(sys.argv):
dbcheck.boot()
from waitress import serve
from YAPO.wsgi import application
#import migrater
from videos import startup
a = 0
if __name__ == '__main__' and a == 0:
startup.startup_sequence()
config = Config().yapo_url
print(f'YAPO configured URL: "{config}"')
if config is None:
print("Using default host/port until one is properly configured.")
config = "127.0.0.1:8000"
a += 1
serve(application, listen=str(Config().yapo_url), threads=10, ident="YAPO", log_socket_errors=False)