rhythmsync 1.0.0__tar.gz → 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rhythmsync-1.1.0/LICENSE +21 -0
- rhythmsync-1.1.0/PKG-INFO +158 -0
- rhythmsync-1.1.0/README.md +135 -0
- {rhythmsync-1.0.0 → rhythmsync-1.1.0}/pyproject.toml +16 -2
- rhythmsync-1.1.0/rhythmsync/command_parser.py +217 -0
- rhythmsync-1.1.0/rhythmsync/converter.py +21 -0
- rhythmsync-1.1.0/rhythmsync/main.py +209 -0
- rhythmsync-1.1.0/rhythmsync/metadata.py +139 -0
- rhythmsync-1.1.0/rhythmsync/player.py +245 -0
- rhythmsync-1.1.0/rhythmsync/terminal_disp.py +52 -0
- rhythmsync-1.1.0/rhythmsync.egg-info/PKG-INFO +158 -0
- {rhythmsync-1.0.0 → rhythmsync-1.1.0}/rhythmsync.egg-info/SOURCES.txt +6 -0
- rhythmsync-1.0.0/PKG-INFO +0 -110
- rhythmsync-1.0.0/README.md +0 -97
- rhythmsync-1.0.0/rhythmsync/main.py +0 -411
- rhythmsync-1.0.0/rhythmsync.egg-info/PKG-INFO +0 -110
- {rhythmsync-1.0.0 → rhythmsync-1.1.0}/rhythmsync/__init__.py +0 -0
- {rhythmsync-1.0.0 → rhythmsync-1.1.0}/rhythmsync.egg-info/dependency_links.txt +0 -0
- {rhythmsync-1.0.0 → rhythmsync-1.1.0}/rhythmsync.egg-info/entry_points.txt +0 -0
- {rhythmsync-1.0.0 → rhythmsync-1.1.0}/rhythmsync.egg-info/requires.txt +0 -0
- {rhythmsync-1.0.0 → rhythmsync-1.1.0}/rhythmsync.egg-info/top_level.txt +0 -0
- {rhythmsync-1.0.0 → rhythmsync-1.1.0}/setup.cfg +0 -0
rhythmsync-1.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 KON/NOS R
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rhythmsync
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: CLI music player with synchronized lyrics (LRC) support
|
|
5
|
+
Author: KON/NOS R
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: music,cli,audio,lrc,player,terminal
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Operating System :: Unix
|
|
12
|
+
Classifier: Operating System :: POSIX
|
|
13
|
+
Classifier: Operating System :: MacOS
|
|
14
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Players
|
|
15
|
+
Classifier: Topic :: Utilities
|
|
16
|
+
Requires-Python: >=3.8
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: pygame
|
|
20
|
+
Requires-Dist: rich
|
|
21
|
+
Requires-Dist: mutagen
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# RhythmSync
|
|
25
|
+
|
|
26
|
+
CLI audio player that plays music while displaying synchronized lyrics (LRC).
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
|
|
32
|
+
- Play audio files in various modes
|
|
33
|
+
- Display synchronized lyrics during playback
|
|
34
|
+
- Show song metadata tags
|
|
35
|
+
- Styled terminal music player UI
|
|
36
|
+
- Convert audio files to other formats using FFmpeg
|
|
37
|
+
- Player controls
|
|
38
|
+
- Pause (`SPACE`)
|
|
39
|
+
- Next (`RIGHT Arrow`)
|
|
40
|
+
- Previous (`LEFT Arrow`)
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Requirements
|
|
45
|
+
|
|
46
|
+
- Python 3.8+
|
|
47
|
+
- FFmpeg (optional, for conversion feature)
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Compatibility
|
|
52
|
+
|
|
53
|
+
RhythmSync is currently intended for UNIX-based systems (Linux/macOS).
|
|
54
|
+
All versions after **1.0.0** don't work with non-UNIX systems
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Installation and Usage
|
|
59
|
+
|
|
60
|
+
- PyPI page: [Click here](https://pypi.org/project/rhythmsync/)
|
|
61
|
+
|
|
62
|
+
<br>
|
|
63
|
+
|
|
64
|
+
- Install the CLI application
|
|
65
|
+
```
|
|
66
|
+
pip install rhythmsync
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- Launch the CLI application:
|
|
70
|
+
```
|
|
71
|
+
rhythmsync
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Supported Audio Formats
|
|
77
|
+
|
|
78
|
+
- `.mp3`
|
|
79
|
+
- `.flac`
|
|
80
|
+
- `.wav`
|
|
81
|
+
- `.ogg`
|
|
82
|
+
|
|
83
|
+
### Notes
|
|
84
|
+
|
|
85
|
+
- Other audio formats might work, but full functionality is not guaranteed.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Lyrics Sync
|
|
90
|
+
|
|
91
|
+
RhythmSync reads embedded lyric metadata from audio files.
|
|
92
|
+
|
|
93
|
+
Supported tags include:
|
|
94
|
+
- `SYLT`, `SYLT::eng`
|
|
95
|
+
- `LYRICS`, `LYRICS:eng`
|
|
96
|
+
- `LYRICS-ENG`, `LYRICS_EN`
|
|
97
|
+
- `LYRICS_SYNCED`, `SYNCEDLYRICS`
|
|
98
|
+
|
|
99
|
+
### LRC Format
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
[00:12.34] First line
|
|
103
|
+
[00:15.67] Second line
|
|
104
|
+
[00:18.90] Third line
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
- Format: `[mm:ss.xx] Line`
|
|
108
|
+
|
|
109
|
+
### Notes
|
|
110
|
+
|
|
111
|
+
- If no lyrics are found, a placeholder message is shown.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Commands
|
|
116
|
+
|
|
117
|
+
### General
|
|
118
|
+
|
|
119
|
+
- `help` - Lists all available commands.
|
|
120
|
+
- `ls` - Lists all files and directories in the current working directory.
|
|
121
|
+
- `ls {path}` - Lists all files and directories in the specified directory.
|
|
122
|
+
- `cd {path}` - Changes the current working directory to the specified directory.
|
|
123
|
+
- `clear` - Clears the terminal.
|
|
124
|
+
|
|
125
|
+
### Playback
|
|
126
|
+
|
|
127
|
+
- `play {path}` - Plays a single audio file once.
|
|
128
|
+
- `play -r {path}` - Plays a single audio file in a loop until stopped (Ctrl+C).
|
|
129
|
+
- `play -d {directory}` - Plays all supported audio files in the specified directory (non-recursive) in alphabetical order.
|
|
130
|
+
- `play -dr {directory}` - Plays all supported audio files in the specified directory (non-recursive) in alphabetical order and loops until stopped (Ctrl+C).
|
|
131
|
+
- `play -ds {directory}` - Plays all supported audio files in the specified directory (non-recursive) in shuffled order and loops until stopped (Ctrl+C).
|
|
132
|
+
- `play -D {path}` - Plays all supported audio files in the specified directory (recursive) in alphabetical order.
|
|
133
|
+
- `play -Dr {path}` - Plays all supported audio files in the specified directory (recursive) in alphabetical order and loops until stopped (Ctrl+C).
|
|
134
|
+
- `play -Ds {path}` - Plays all supported audio files in the specified directory (recursive) in shuffled order and loops until stopped (Ctrl+C).
|
|
135
|
+
|
|
136
|
+
### Metadata
|
|
137
|
+
|
|
138
|
+
- `info {path}` - Displays all available metadata.
|
|
139
|
+
- `info {path} [tags]` - Displays only given metadata tags.
|
|
140
|
+
|
|
141
|
+
### Converter
|
|
142
|
+
|
|
143
|
+
- `convert {input path} {output path}` - Converts an audio file to another format (FFmpeg required).
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Notes
|
|
148
|
+
|
|
149
|
+
- Paths containing spaces must be wrapped in quotes or escaped with backslashes:
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
play "My Music/song.mp3"
|
|
153
|
+
play My\ Music/song.mp3
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
- The **convert** command uses FFmpeg and may alter or corrupt metadata
|
|
157
|
+
|
|
158
|
+
- Use `Ctrl+C` to stop playback or exit the app
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# RhythmSync
|
|
2
|
+
|
|
3
|
+
CLI audio player that plays music while displaying synchronized lyrics (LRC).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Play audio files in various modes
|
|
10
|
+
- Display synchronized lyrics during playback
|
|
11
|
+
- Show song metadata tags
|
|
12
|
+
- Styled terminal music player UI
|
|
13
|
+
- Convert audio files to other formats using FFmpeg
|
|
14
|
+
- Player controls
|
|
15
|
+
- Pause (`SPACE`)
|
|
16
|
+
- Next (`RIGHT Arrow`)
|
|
17
|
+
- Previous (`LEFT Arrow`)
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Requirements
|
|
22
|
+
|
|
23
|
+
- Python 3.8+
|
|
24
|
+
- FFmpeg (optional, for conversion feature)
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Compatibility
|
|
29
|
+
|
|
30
|
+
RhythmSync is currently intended for UNIX-based systems (Linux/macOS).
|
|
31
|
+
All versions after **1.0.0** don't work with non-UNIX systems
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Installation and Usage
|
|
36
|
+
|
|
37
|
+
- PyPI page: [Click here](https://pypi.org/project/rhythmsync/)
|
|
38
|
+
|
|
39
|
+
<br>
|
|
40
|
+
|
|
41
|
+
- Install the CLI application
|
|
42
|
+
```
|
|
43
|
+
pip install rhythmsync
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- Launch the CLI application:
|
|
47
|
+
```
|
|
48
|
+
rhythmsync
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Supported Audio Formats
|
|
54
|
+
|
|
55
|
+
- `.mp3`
|
|
56
|
+
- `.flac`
|
|
57
|
+
- `.wav`
|
|
58
|
+
- `.ogg`
|
|
59
|
+
|
|
60
|
+
### Notes
|
|
61
|
+
|
|
62
|
+
- Other audio formats might work, but full functionality is not guaranteed.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Lyrics Sync
|
|
67
|
+
|
|
68
|
+
RhythmSync reads embedded lyric metadata from audio files.
|
|
69
|
+
|
|
70
|
+
Supported tags include:
|
|
71
|
+
- `SYLT`, `SYLT::eng`
|
|
72
|
+
- `LYRICS`, `LYRICS:eng`
|
|
73
|
+
- `LYRICS-ENG`, `LYRICS_EN`
|
|
74
|
+
- `LYRICS_SYNCED`, `SYNCEDLYRICS`
|
|
75
|
+
|
|
76
|
+
### LRC Format
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
[00:12.34] First line
|
|
80
|
+
[00:15.67] Second line
|
|
81
|
+
[00:18.90] Third line
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
- Format: `[mm:ss.xx] Line`
|
|
85
|
+
|
|
86
|
+
### Notes
|
|
87
|
+
|
|
88
|
+
- If no lyrics are found, a placeholder message is shown.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Commands
|
|
93
|
+
|
|
94
|
+
### General
|
|
95
|
+
|
|
96
|
+
- `help` - Lists all available commands.
|
|
97
|
+
- `ls` - Lists all files and directories in the current working directory.
|
|
98
|
+
- `ls {path}` - Lists all files and directories in the specified directory.
|
|
99
|
+
- `cd {path}` - Changes the current working directory to the specified directory.
|
|
100
|
+
- `clear` - Clears the terminal.
|
|
101
|
+
|
|
102
|
+
### Playback
|
|
103
|
+
|
|
104
|
+
- `play {path}` - Plays a single audio file once.
|
|
105
|
+
- `play -r {path}` - Plays a single audio file in a loop until stopped (Ctrl+C).
|
|
106
|
+
- `play -d {directory}` - Plays all supported audio files in the specified directory (non-recursive) in alphabetical order.
|
|
107
|
+
- `play -dr {directory}` - Plays all supported audio files in the specified directory (non-recursive) in alphabetical order and loops until stopped (Ctrl+C).
|
|
108
|
+
- `play -ds {directory}` - Plays all supported audio files in the specified directory (non-recursive) in shuffled order and loops until stopped (Ctrl+C).
|
|
109
|
+
- `play -D {path}` - Plays all supported audio files in the specified directory (recursive) in alphabetical order.
|
|
110
|
+
- `play -Dr {path}` - Plays all supported audio files in the specified directory (recursive) in alphabetical order and loops until stopped (Ctrl+C).
|
|
111
|
+
- `play -Ds {path}` - Plays all supported audio files in the specified directory (recursive) in shuffled order and loops until stopped (Ctrl+C).
|
|
112
|
+
|
|
113
|
+
### Metadata
|
|
114
|
+
|
|
115
|
+
- `info {path}` - Displays all available metadata.
|
|
116
|
+
- `info {path} [tags]` - Displays only given metadata tags.
|
|
117
|
+
|
|
118
|
+
### Converter
|
|
119
|
+
|
|
120
|
+
- `convert {input path} {output path}` - Converts an audio file to another format (FFmpeg required).
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Notes
|
|
125
|
+
|
|
126
|
+
- Paths containing spaces must be wrapped in quotes or escaped with backslashes:
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
play "My Music/song.mp3"
|
|
130
|
+
play My\ Music/song.mp3
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
- The **convert** command uses FFmpeg and may alter or corrupt metadata
|
|
134
|
+
|
|
135
|
+
- Use `Ctrl+C` to stop playback or exit the app
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "rhythmsync"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.1.0"
|
|
8
8
|
description = "CLI music player with synchronized lyrics (LRC) support"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
|
@@ -21,5 +21,19 @@ dependencies = [
|
|
|
21
21
|
"mutagen"
|
|
22
22
|
]
|
|
23
23
|
|
|
24
|
+
classifiers = [
|
|
25
|
+
"Programming Language :: Python :: 3",
|
|
26
|
+
"License :: OSI Approved :: MIT License",
|
|
27
|
+
"Environment :: Console",
|
|
28
|
+
"Operating System :: Unix",
|
|
29
|
+
"Operating System :: POSIX",
|
|
30
|
+
"Operating System :: MacOS",
|
|
31
|
+
"Topic :: Multimedia :: Sound/Audio :: Players",
|
|
32
|
+
"Topic :: Utilities"
|
|
33
|
+
]
|
|
34
|
+
|
|
24
35
|
[project.scripts]
|
|
25
|
-
rhythmsync = "rhythmsync.main:main"
|
|
36
|
+
rhythmsync = "rhythmsync.main:main"
|
|
37
|
+
|
|
38
|
+
[tool.setuptools]
|
|
39
|
+
packages = ["rhythmsync"]
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from rich.console import Console
|
|
3
|
+
console = Console()
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from random import shuffle
|
|
6
|
+
import shlex
|
|
7
|
+
|
|
8
|
+
import rhythmsync.player as player
|
|
9
|
+
import rhythmsync.metadata as metadata
|
|
10
|
+
import rhythmsync.converter as converter
|
|
11
|
+
import rhythmsync.terminal_disp as terminal_disp
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def parse_command(raw_command):
|
|
15
|
+
if raw_command.strip():
|
|
16
|
+
command = shlex.split(raw_command)
|
|
17
|
+
command_parts = len(command)
|
|
18
|
+
|
|
19
|
+
#help command
|
|
20
|
+
if command[0] == "help" and command_parts == 1:
|
|
21
|
+
terminal_disp.help_msg()
|
|
22
|
+
|
|
23
|
+
#list command
|
|
24
|
+
elif command[0] == "ls":
|
|
25
|
+
if command_parts == 1:
|
|
26
|
+
console.print(f"[blue]{" ".join(os.listdir())}", highlight=False)
|
|
27
|
+
elif command_parts == 2:
|
|
28
|
+
directory = str(Path(command[1]).expanduser().resolve())
|
|
29
|
+
if os.path.exists(directory):
|
|
30
|
+
console.print(f"[blue]{" ".join(os.listdir(directory))}", highlight=False)
|
|
31
|
+
else:
|
|
32
|
+
print("Please enter valid parameters.")
|
|
33
|
+
|
|
34
|
+
#change directory command
|
|
35
|
+
elif command[0] == "cd" and command_parts == 2:
|
|
36
|
+
directory = str(Path(command[1]).expanduser().resolve())
|
|
37
|
+
if os.path.exists(directory):
|
|
38
|
+
os.chdir(directory)
|
|
39
|
+
else:
|
|
40
|
+
print("Please enter a valid file path.")
|
|
41
|
+
|
|
42
|
+
#clear command
|
|
43
|
+
elif command[0] == "clear" and command_parts == 1:
|
|
44
|
+
terminal_disp.clear_screen()
|
|
45
|
+
terminal_disp.logo()
|
|
46
|
+
|
|
47
|
+
#play command
|
|
48
|
+
elif command[0] == "play":
|
|
49
|
+
if command_parts == 2: #single
|
|
50
|
+
file_path = str(Path(command[1]).expanduser().resolve())
|
|
51
|
+
if os.path.exists(file_path):
|
|
52
|
+
repeat = True
|
|
53
|
+
while repeat:
|
|
54
|
+
repeat = player.run_player(file_path, "single")[0]
|
|
55
|
+
terminal_disp.clear_screen()
|
|
56
|
+
terminal_disp.logo()
|
|
57
|
+
else:
|
|
58
|
+
print("Please enter a valid file path.")
|
|
59
|
+
|
|
60
|
+
elif command_parts == 3:
|
|
61
|
+
par = command[1]
|
|
62
|
+
file_path = str(Path(command[2]).expanduser().resolve())
|
|
63
|
+
if os.path.exists(file_path):
|
|
64
|
+
if par == "-r": #single repeat
|
|
65
|
+
repeat = True
|
|
66
|
+
while repeat:
|
|
67
|
+
repeat = player.run_player(file_path, "repeat")[0]
|
|
68
|
+
terminal_disp.clear_screen()
|
|
69
|
+
terminal_disp.logo()
|
|
70
|
+
|
|
71
|
+
elif par[:2] == "-d": #directory modes
|
|
72
|
+
extensions = (".mp3", ".flac", ".wav", ".ogg")
|
|
73
|
+
audio_files = [
|
|
74
|
+
f for f in Path(file_path).iterdir()
|
|
75
|
+
if f.suffix.lower() in extensions
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
if par == "-d": #dir
|
|
79
|
+
if audio_files:
|
|
80
|
+
audio_files.sort()
|
|
81
|
+
repeat = True
|
|
82
|
+
i = 1
|
|
83
|
+
while i-1 < len(audio_files) and i >= 1 and repeat:
|
|
84
|
+
for j in range(i-1, len(audio_files)):
|
|
85
|
+
repeat, i = player.run_player(audio_files[j], f"directory {i} {len(audio_files)}")
|
|
86
|
+
if i < 1:
|
|
87
|
+
i = 1
|
|
88
|
+
break
|
|
89
|
+
terminal_disp.clear_screen()
|
|
90
|
+
terminal_disp.logo()
|
|
91
|
+
else:
|
|
92
|
+
print("No audio files found.")
|
|
93
|
+
|
|
94
|
+
elif par == "-dr": #dir repeat
|
|
95
|
+
if audio_files:
|
|
96
|
+
audio_files.sort()
|
|
97
|
+
repeat = True
|
|
98
|
+
i = 1
|
|
99
|
+
while repeat:
|
|
100
|
+
for j in range(i-1, len(audio_files)):
|
|
101
|
+
repeat, i = player.run_player(audio_files[j], f"directory {i} {len(audio_files)}")
|
|
102
|
+
if i < 1:
|
|
103
|
+
i = len(audio_files)
|
|
104
|
+
elif i > len(audio_files):
|
|
105
|
+
i = 1
|
|
106
|
+
break
|
|
107
|
+
terminal_disp.clear_screen()
|
|
108
|
+
terminal_disp.logo()
|
|
109
|
+
else:
|
|
110
|
+
print("No audio files found.")
|
|
111
|
+
|
|
112
|
+
elif par == "-ds": #dir shuffle
|
|
113
|
+
if audio_files:
|
|
114
|
+
shuffle(audio_files)
|
|
115
|
+
repeat = True
|
|
116
|
+
i = 1
|
|
117
|
+
while repeat:
|
|
118
|
+
for j in range(i-1, len(audio_files)):
|
|
119
|
+
repeat, i = player.run_player(audio_files[j], f"directory {i} {len(audio_files)}")
|
|
120
|
+
if i < 1:
|
|
121
|
+
i = len(audio_files)
|
|
122
|
+
elif i > len(audio_files):
|
|
123
|
+
i = 1
|
|
124
|
+
break
|
|
125
|
+
terminal_disp.clear_screen()
|
|
126
|
+
terminal_disp.logo()
|
|
127
|
+
else:
|
|
128
|
+
print("No audio files found.")
|
|
129
|
+
|
|
130
|
+
elif par[:2] == "-D": #recursive modes
|
|
131
|
+
extensions = (".mp3", ".flac", ".wav", ".ogg")
|
|
132
|
+
audio_files = [
|
|
133
|
+
f for f in Path(file_path).rglob("*")
|
|
134
|
+
if f.suffix.lower() in extensions
|
|
135
|
+
]
|
|
136
|
+
|
|
137
|
+
if par == "-D": #dirs
|
|
138
|
+
if audio_files:
|
|
139
|
+
audio_files.sort()
|
|
140
|
+
repeat = True
|
|
141
|
+
i = 1
|
|
142
|
+
while i-1 < len(audio_files) and i >= 1 and repeat:
|
|
143
|
+
for j in range(i-1, len(audio_files)):
|
|
144
|
+
repeat, i = player.run_player(audio_files[j], f"directory {i} {len(audio_files)}")
|
|
145
|
+
if i < 1:
|
|
146
|
+
i = 1
|
|
147
|
+
break
|
|
148
|
+
terminal_disp.clear_screen()
|
|
149
|
+
terminal_disp.logo()
|
|
150
|
+
else:
|
|
151
|
+
print("No audio files found.")
|
|
152
|
+
|
|
153
|
+
elif par == "-Dr": #dir repeat
|
|
154
|
+
if audio_files:
|
|
155
|
+
audio_files.sort()
|
|
156
|
+
repeat = True
|
|
157
|
+
i = 1
|
|
158
|
+
while repeat:
|
|
159
|
+
for j in range(i-1, len(audio_files)):
|
|
160
|
+
repeat, i = player.run_player(audio_files[j], f"directory {i} {len(audio_files)}")
|
|
161
|
+
if i < 1:
|
|
162
|
+
i = len(audio_files)
|
|
163
|
+
elif i > len(audio_files):
|
|
164
|
+
i = 1
|
|
165
|
+
break
|
|
166
|
+
terminal_disp.clear_screen()
|
|
167
|
+
terminal_disp.logo()
|
|
168
|
+
else:
|
|
169
|
+
print("No audio files found.")
|
|
170
|
+
|
|
171
|
+
elif par == "-Ds": #dir shuffle
|
|
172
|
+
if audio_files:
|
|
173
|
+
shuffle(audio_files)
|
|
174
|
+
repeat = True
|
|
175
|
+
i = 1
|
|
176
|
+
while repeat:
|
|
177
|
+
for j in range(i-1, len(audio_files)):
|
|
178
|
+
repeat, i = player.run_player(audio_files[j], f"directory {i} {len(audio_files)}")
|
|
179
|
+
if i < 1:
|
|
180
|
+
i = len(audio_files)
|
|
181
|
+
elif i > len(audio_files):
|
|
182
|
+
i = 1
|
|
183
|
+
break
|
|
184
|
+
terminal_disp.clear_screen()
|
|
185
|
+
terminal_disp.logo()
|
|
186
|
+
else:
|
|
187
|
+
print("No audio files found.")
|
|
188
|
+
else:
|
|
189
|
+
print("Please enter a valid file path.")
|
|
190
|
+
else:
|
|
191
|
+
print("Please enter a valid file path and parameters.")
|
|
192
|
+
|
|
193
|
+
#info command
|
|
194
|
+
elif command[0] == "info":
|
|
195
|
+
if command_parts >= 2:
|
|
196
|
+
file_path = Path(command[1]).expanduser().resolve()
|
|
197
|
+
par = tuple(command[2:]) or None
|
|
198
|
+
if os.path.exists(file_path):
|
|
199
|
+
console.print(metadata.get_metadata(file_path, par), highlight=False)
|
|
200
|
+
else:
|
|
201
|
+
print("Please enter a valid file path.")
|
|
202
|
+
else:
|
|
203
|
+
print("Please enter a valid file path and parameters.")
|
|
204
|
+
|
|
205
|
+
#convert command
|
|
206
|
+
elif command[0] == "convert" and command_parts == 3:
|
|
207
|
+
input_path = Path(command[1]).expanduser().resolve()
|
|
208
|
+
output_path = Path(command[2]).expanduser().resolve()
|
|
209
|
+
output_dir = Path("/".join(command[2].split("/")[:-1])).expanduser().resolve()
|
|
210
|
+
if os.path.exists(input_path) and os.path.exists(output_dir):
|
|
211
|
+
converter.convert(input_path, output_path)
|
|
212
|
+
else:
|
|
213
|
+
print("Please enter valid file paths.")
|
|
214
|
+
|
|
215
|
+
#invalid command
|
|
216
|
+
else:
|
|
217
|
+
print("Invalid command! Enter 'help' to display command list.")
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import subprocess
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
#converts audio file to other formats
|
|
5
|
+
def convert(input_file, output_file):
|
|
6
|
+
try:
|
|
7
|
+
subprocess.run([
|
|
8
|
+
"ffmpeg",
|
|
9
|
+
"-y",
|
|
10
|
+
"-i", input_file,
|
|
11
|
+
output_file
|
|
12
|
+
], check=True)
|
|
13
|
+
|
|
14
|
+
print(f"Converted successfully:")
|
|
15
|
+
print(f"{input_file} -> {output_file}")
|
|
16
|
+
|
|
17
|
+
except FileNotFoundError:
|
|
18
|
+
print("FFmpeg is not installed.")
|
|
19
|
+
|
|
20
|
+
except subprocess.CalledProcessError:
|
|
21
|
+
print("Conversion failed.")
|