-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshared.py
More file actions
42 lines (34 loc) · 1.17 KB
/
shared.py
File metadata and controls
42 lines (34 loc) · 1.17 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
import bs4 as BeautifulSoup
import os
class shared:
global drive
# upon updates, receive the drive from user
global comic_directory
def main_directory(link):
global manga_directory
global parent_directory
drive = 'F:'
comic_directory = 'Comics'
soup = BeautifulSoup
manga_directory = link.split('/')[-1].replace("-", " ").title()
parent_directory = os.path.join(drive, comic_directory, manga_directory)
print(parent_directory)
if not os.path.exists(parent_directory):
try:
os.mkdir(parent_directory)
except:
manga_directory = ' '.join(manga_directory.split(':'))
parent_directory = os.path.join(drive, comic_directory, manga_directory)
if not os.path.exists(parent_directory):
os.mkdir(parent_directory)
parent_directory = os.path.join(drive, comic_directory, manga_directory)
print(manga_directory)
return None
def chapter_directory(chapter):
chapter = str(chapter)
chapter_dir = os.path.join(parent_directory, chapter)
if os.path.exists(chapter_dir):
pass
else:
os.mkdir(chapter_dir)
return chapter_dir