aboutsummaryrefslogtreecommitdiff
path: root/scripts/mangasort
blob: d46be69c8e1ec16d64549c83e6270f5822148145 (plain)
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
#!/bin/python

import os

def sxivInput(r1, r2):
    return "sxiv " + r1 + " & " + "sxiv " + r2 + " & "

def calculate(prefix, suffix, num):
    r1 = ''
    r2 = ''
   
    i = 1
    while i <= num:  # r1
        if i < 10:
            ai = "00" + str(i)
        elif i < 100:
            ai = "0" + str(i)
        else:
            ai = i
        r1 += prefix + str(ai) + suffix + " "
        i += 2
    
    i = 2
    while i <= num:  # ra
        if i < 10:
            ai = "00" + str(i)
        elif i < 100:
            ai = "0" + str(i)
        else:
            ai = i
        r2 += prefix + str(ai) + suffix + " "
        i += 2

    return r1, r2

def tachiyomi(i):
    r1, r2 = calculate('', '.png', i)
    os.system(sxivInput(r1, r2))

def main():
    titlePrefix = input("Title prefix: ")
    titleSuffix = input("Title suffix: ")
    numPages = int(input("Number of pages: "))

    r1, r2 = calculate(titlePrefix, titleSuffix, numPages)
    print(sxivInput(r1, r2))

if __name__ == '__main__':
    contents = os.listdir(os.getcwd())
    c = set(contents)

    if "001.png" in c:
        tachiyomi(len(contents))
    else:
        main()