Skip to content

Commit

Permalink
Merge pull request #8 from dan-sazonov/dev
Browse files Browse the repository at this point in the history
Release v1.6.1
  • Loading branch information
dan-sazonov authored Oct 3, 2023
2 parents 84f45ce + 17bcb90 commit 2d4ad21
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 10 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ $ python3 main.py
After that, the program will ask for the path to the directory where the tracks need to be edited. Then change the value of each parameter
for each file. If you want to apply the value from the brackets, press \[Enter\]. You can use a parser to search for the album name. Just enter \[\!] instead of the album name. Also, the name of the band and track are copied to the clipboard. It looks like this:

<p align="center"><img src="./img/demo1.png" width="555" height="253"></p>
<p align="center"><img src="./img/demo1.png" width="555" height="253" alt="Main process screenshot"></p>

<h3>Default Parameters</h3>

If there is a same values for each tracks in this folder, you can predefine it by specifying one of the flags when starting the program (see below). The value of this
parameter will be asked once at start, and will be applied to all tracks. It looks like this:

<p align="center"><img src="./img/demo2.png" width="556" height="373"></p>
<p align="center"><img src="./img/demo2.png" width="556" height="373" alt="Usage with the presets of some data screenshot"></p>
<details>
<summary><b>Flags:</b></summary>
<ul>
Expand All @@ -56,15 +56,17 @@ The log will be saved if the program was terminated with an error. You can also
}
}
```
You can restore metadata based on information from any log file. For example, this may be useful if you have the same files in different directories and you need to edit
them all. Run the program with the `-p` or `--parse` flag, set the log file and enter the path to the required directory. Any others flags except `-r` or `--rename` will be ignored.
You can restore metadata based on information from any log file. For example, this may be useful if you have the same files in different directories, and you need to edit
them all. Run the program with the `-p` or `--parse` flag, set the log file and enter the path to the required directory. Any other flags except `-r` or `--rename` will be ignored.

Also you can write the current unchanged metadata to a json file. To do this, run the program with the `-s` or `--scan` flag. I call this **manual mode** - at first you
Also, you can write the current unchanged metadata to a json file. To do this, run the program with the `-s` or `--scan` flag. I call this **manual mode** - at first you
create a json file with the unchanged metadata, then you edit them and apply it by running the program with the `-p` or `--parse` flag.

If you need to print artist-title pairs for all tracks, use the `--min_scan` flag.

<h3>More Features</h3>

- If the file contains information about the copyright holder and you want to leave it, use the `-c` or `--copyright` flag.
- If the file contains information about the copyright holder, and you want to leave it, use the `-c` or `--copyright` flag.
- You can run the program in minimal mode with `-m` or `--minimal` flag. It will only ask for title, artist, album and genre. Other data will be cleared.
- Files could be renamed in the form of `artist_track-title.mp3`. Use the `-r` or `--rename` flag. Keep in mind that the information in the logs will be associated with the new name at the regular end of the program.
- You can also rename all files without changing the metadata. Run the program with the `--auto_rename` flag. Don't use other flags with this.
Expand Down
6 changes: 4 additions & 2 deletions README_ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ $ python3 main.py
После этого программа спросит путь к директории, треки в которой надо отредактировать. Затем измени значение каждого параметра
для каждого файла. Если ты хочешь применить значение из скобок, нажми \[Enter\]. Для поиска названия альбома можно использовать парсер. Просто введи \[\!] вместо названия альбома. Также название группы и трэка копируются в буфер обмена. Это выглядит так:

<p align="center"><img src="./img/demo1.png" width="555" height="253"></p>
<p align="center"><img src="./img/demo1.png" width="555" height="253" alt="Скриншот основного процесса"></p>

<h3>Параметры по дефолту</h3>

Если какие-то параметры одинаковые для всех треков в этой директории, ты можешь предустановить их, указав соответствующие
флаги перед запуском программы (см. ниже). Значение этих параметров будут спрошены однажды перед запуском и будут применены
ко всем трекам. Это выглядит так:

<p align="center"><img src="./img/demo2.png" width="556" height="373"></p>
<p align="center"><img src="./img/demo2.png" width="556" height="373" alt="Скриншот использования с некотрыми предустановленными данными"></p>
<details>
<summary><b>Флаги:</b></summary>
<ul>
Expand Down Expand Up @@ -65,6 +65,8 @@ $ python3 main.py
это **ручным режимом** - сначала ты создаешь файл с текущими метаданными, затем редактируешь его и применяешь данные к
файлам, запустив программу с флагом `-p` или `--parse`.

Если вам нужно распечатать пары вида "артист - название" для всех треков, используйте флаг `--min_scan`.

<h3>Больше возможностей</h3>

- Если файлы содержат информацию о правообладателе, и ты хочешь сохранить ее, используй флаг `-c` или `--copyright`.
Expand Down
3 changes: 3 additions & 0 deletions cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def set_parser():
help='delete all metadata from these tracks')
parser.add_argument('-s', '--scan', action='store_true', default=False,
help='create the log file with the current values of the metadata')
parser.add_argument('--min_scan', action='store_true', default=False,
help='print out "artist-title" pairs for all tracks')
parser.add_argument('-r', '--rename', action='store_true', default=False,
help='rename the files in the form of artist_track')
parser.add_argument('--auto_rename', action='store_true', default=False,
Expand Down Expand Up @@ -56,6 +58,7 @@ def set_parser():
del_mode = cli_args.delete
parse_mode = cli_args.parse
scan_mode = cli_args.scan
min_scan = cli_args.min_scan
min_mode = cli_args.minimal
rename_mode = cli_args.auto_rename

Expand Down
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
VERSION = {
'major': 1,
'minor': 6,
'micro': 0
'micro': 1
}

AUTHOR = 'Dan Sazonov'
Expand Down
11 changes: 11 additions & 0 deletions features.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ def get_track_title(track: EasyID3) -> list[str, str]:
return clip


def get_title_pairs(track: EasyID3) -> str:
"""
Get nice string from the data of file
:param track: mutagen object, metadata of this track
:return: "artist - title"
"""
track_title = get_track_title(track)
return f'{track_title[0]} - {track_title[1]}'


def copy_track_title(track: EasyID3) -> None:
"""
Save artist and title of this track to the clipboard
Expand Down
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,12 @@ def main():
file_title = os.path.split(file)[-1]

tmp_log, need_returns = (dict(), False) if cli.del_mode else (dict(EasyID3(file)), False) \
if (cli.scan_mode or cli.rename_mode) else ask_user(file, default, ignored)
if (cli.scan_mode or cli.rename_mode or cli.min_scan) else ask_user(file, default, ignored)
cur_index += -1 if need_returns else 1

logger.update_log(file_title, tmp_log)
if cli.min_scan:
print(features.get_title_pairs(tmp_log))

if cli.parse_mode:
logger.parse_log()
Expand Down

0 comments on commit 2d4ad21

Please sign in to comment.