-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload_foltia.py
54 lines (45 loc) · 1.65 KB
/
upload_foltia.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
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
import pathlib
import glob
FOLTIA_DIR = '/mnt/foltia'
# キーワード録画
for p in glob.glob('{}/04-キーワード録画/*'.format(FOLTIA_DIR)):
path = pathlib.Path(p)
pname = path.name
# /はgoogle driveでうまく扱えない?
gpname = pname.replace("/", "-")
ldir = "links/keyword/{}".format(gpname)
try:
os.makedirs(ldir)
except FileExistsError as e:
pass
try:
os.makedirs("lists/keyword")
except FileExistsError as e:
pass
listfilepath = "lists/keyword/{}.txt".format(gpname)
listfile = open(listfilepath, "w")
for f in path.glob('*/*/MP4-HD/*.MP4'):
lpname = os.path.join(ldir, os.path.basename(f))
try:
os.symlink(f, lpname)
except FileExistsError as e:
os.remove(lpname)
os.symlink(f, lpname)
listfile.write("{}\n".format(os.path.basename(f)))
print('rclone -v copy -L --size-only --files-from="{}" "{}" "365g:/foltia/keyword/{}/"'.format(listfilepath, os.path.join(os.getcwd(), ldir), gpname))
# アニメ自動録画
for p in glob.glob('{}/02-アニメ自動録画/*/*/*'.format(FOLTIA_DIR)):
path = pathlib.Path(p)
pname = path.name
try:
os.makedirs("lists/anime")
except FileExistsError as e:
pass
listfilepath = "lists/anime/{}.txt".format(pname)
listfile = open(listfilepath, "w")
for f in path.glob('MP4-HD/*.MP4'):
listfile.write("{}\n".format(pathlib.Path(f).name))
print('rclone -v copy --size-only --files-from="{}" "{}" "365g:/foltia/anime/{}/"'.format(listfilepath, path / "MP4-HD", pname))