-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_source.py
More file actions
137 lines (123 loc) · 4.06 KB
/
Copy pathgenerate_source.py
File metadata and controls
137 lines (123 loc) · 4.06 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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# Copyright (c) 2025 iiPython
# Modules
import textwrap
# Initialization
VERSION = "1.2"
FIELDS = {
"version": {
"size": 9
},
"type": {
"name": "Type of content (Anime/TV/Movie/...)?",
"size": 13
},
"name": {
"name": "Name of content:",
"size": 34
},
"year": {
"name": "Year of content:",
"size": 4
},
"added": {
"name": "The original add date:",
"size": 21
},
"modified": {
"name": "Update date (N/A if not updated):",
"size": 19
},
"vcodec": {
"name": "Video codec:",
"size": 8
},
"resolution": {
"name": "Video resolution:",
"size": 10
},
"vcomment": {
"name": "Video comment (blank for N/A):",
"size": 19
},
"acodec": {
"name": "Audio codec:",
"size": 8
},
"bitrate": {
"name": "Audio bitrate (including 'kbps'):",
"size": 10
},
"acomment": {
"name": "Audio comment (blank for N/A):",
"size": 19
},
"source": {
"name": "Content source (blank for N/A):",
"size": 43
},
"url": {
"name": "Source URL (blank for N/A):",
"size": 43
},
"torrent": {
"name": "Torrent magnet (blank for N/A):",
"size": 10000
},
"comment": {
"name": "General comment (blank for N/A):",
"size": 10000
}
}
# Start asking questions
answers = {}
for field, data in FIELDS.items():
if "name" not in data:
continue
while True:
answers[field] = input(data["name"] + " ") or "N/A"
if len(answers[field]) <= data["size"]:
break
print("Content too large, please retype.")
# UI handling
def pad(field: str, value: str | None = None) -> str:
if value is None:
value = str(answers[field])
if field not in FIELDS:
raise RuntimeError("The specified field was not found!")
if field in ["torrent", "comment"]:
return "\n".join(textwrap.TextWrapper(43).wrap(value))
if len(value) > FIELDS[field]["size"]:
raise RuntimeError("The content is too big to fit in the field!")
return f"{value}{' ' * (FIELDS[field]['size'] - len(value))}"
# Build the torrent field
torrent = "\n".join([
f"│ {line}{' ' * (43 - len(line))} │"
for line in pad("torrent").split("\n")
])
# Build the comment field
comment = "\n".join([
f"│ {line}{' ' * (43 - len(line))} │"
for line in pad("comment").split("\n")
])
# Begin building the general file
built_file = f"""\
┌─ Info ──────────┬─ Version ─┬─ Category ────┐
│ iiPython Schema │ {pad('version', VERSION)} │ {pad('type')} │
├─ Name ──────────┴───────────┴──────┬─ Year ─┤
│ {pad('name')} │ {pad('year') } │
├─ Added ───────────────┬─ Updated ──┴────────┤
│ {pad('added')} │ {pad('modified')} │
├─ Codec ──┬─ VR ───────┼─ Comments ──────────┤
│ {pad('vcodec')} │ {pad('resolution')} │ {pad('vcomment')} │
├─ Codec ──┼─ Bitrate ──┼─ Comments ──────────┤
│ {pad('acodec')} │ {pad('bitrate')} │ {pad('acomment')} │
├─ Source ─┴────────────┴─────────────────────┤
│ {pad('source')} │
├─ URL ───────────────────────────────────────┤
│ {pad('url')} │
├─ Torrent ───────────────────────────────────┤
{torrent}
├─ Comment ───────────────────────────────────┤
{comment}
└─────────────────────────────────────────────┘"""
print(built_file)