Skip to content

Commit daa2e83

Browse files
committed
✨ built-in files
1 parent 179c32f commit daa2e83

2 files changed

Lines changed: 29 additions & 21 deletions

File tree

src/badapple/__main__.py

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,9 @@
77
from .audio import help_audio
88
from .players import get_names
99
from .util import get_info
10+
from .builtin_files import BA_BA, BA_MP4,BA_MP3, BA_WAV, ba_get
1011

1112
if __name__ == "__main__":
12-
D_DIR = os.path.dirname(__file__)
13-
D_MP3 = '_BA_MP3'
14-
D_MP4 = '_BA_MP4'
15-
D_WAV = '_BA_WAV'
16-
D_BA = '_BA_BA'
17-
D_FILES = {
18-
D_MP3: os.path.join(D_DIR, 'badapple.mp3'),
19-
D_MP4: os.path.join(D_DIR, 'badapple.mp4'),
20-
D_WAV: os.path.join(D_DIR, 'badapple.wav'),
21-
D_BA: os.path.join(D_DIR, 'badapple.badapple'),
22-
}
23-
2413
parser = argparse.ArgumentParser(
2514
'badapple',
2615
'badapple [options] ... ',
@@ -36,10 +25,10 @@
3625
parser.add_argument(
3726
'-i', '--input',
3827
help='video file (use %s or %s to load built-in video)' % (
39-
D_MP4,
40-
D_BA,
28+
BA_MP4,
29+
BA_BA,
4130
),
42-
default=D_MP4
31+
default=BA_MP4
4332
)
4433
parser.add_argument(
4534
'-o', '--output',
@@ -54,9 +43,10 @@
5443
)
5544
parser.add_argument(
5645
'--audio',
57-
help='audio file (use %s or %s to load built-in audio)' % (
58-
D_WAV,
59-
D_MP3,
46+
help='audio file (use %s, %s or %s to load built-in audio)' % (
47+
BA_WAV,
48+
BA_MP3,
49+
BA_MP4,
6050
),
6151
default=''
6252
)
@@ -102,7 +92,7 @@
10292

10393
a = parser.parse_args()
10494

105-
if a.avaliable_player:
95+
if a.help_audio:
10696
help_audio()
10797
sys.exit(0)
10898

@@ -113,8 +103,8 @@
113103

114104
p_list: list[Process] = list()
115105

116-
video = D_FILES.get(a.input, a.input)
117-
audio = D_FILES.get(a.audio, a.audio)
106+
video = ba_get(a.input)
107+
audio = ba_get(a.audio)
118108

119109
try:
120110
play(

src/badapple/builtin_files.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import os
2+
3+
BA_DIR = os.path.dirname(__file__)
4+
BA_MP3 = '_BA_MP3'
5+
BA_MP4 = '_BA_MP4'
6+
BA_WAV = '_BA_WAV'
7+
BA_BA = '_BA_BA'
8+
9+
__FILES = {
10+
BA_MP3: os.path.join(BA_DIR, 'badapple.mp3'),
11+
BA_MP4: os.path.join(BA_DIR, 'badapple.mp4'),
12+
BA_WAV: os.path.join(BA_DIR, 'badapple.wav'),
13+
BA_BA: os.path.join(BA_DIR, 'badapple.badapple'),
14+
}
15+
16+
17+
def ba_get(x: str) -> str:
18+
return __FILES.get(x, x)

0 commit comments

Comments
 (0)