Skip to content

Commit

Permalink
Merge pull request #9 from dan-sazonov/dev
Browse files Browse the repository at this point in the history
Release v1.6.2
  • Loading branch information
dan-sazonov authored Oct 22, 2023
2 parents 2d4ad21 + 7b6f9ce commit 93cbd8d
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 20 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

**The simplest console tool for batch editing of mp3 metadata in interactive or manual mode**

> Now this version of the project is in the active stage of refactoring. A roadmap of planned changes will be added later. If you want to contribute to the project already at this stage, please contact the author.
## 📦 Installation
Clone this repo, change the directory and install the necessary requirements:
```
Expand Down Expand Up @@ -62,7 +64,7 @@ them all. Run the program with the `-p` or `--parse` flag, set the log file and
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.
If you need to print artist-title pairs for all tracks, use the `--min_scan` flag. The output information will be copied to the clipboard. The `DO_OUTPUT_COPY` flag in the file `config.py` is responsible for this behavior.

<h3>More Features</h3>

Expand Down
4 changes: 3 additions & 1 deletion README_ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

**Простейшая консольная тулза для редактирования метаданных mp3 файлов в интерактивном режиме**

> Сейчас данная версия проекта находится в активной стадии рефакторинга. Позже будет добавлена дорожная карта планируемых изменений. Если вы хотите внести вклад в проект уже на данном этапе, пожалуйста, свяжитесь с автором.
## 📦 Установка
Склонируй этот репозиторий, перейди в новую директорию и установи нужные пакеты:
```
Expand Down Expand Up @@ -65,7 +67,7 @@ $ python3 main.py
это **ручным режимом** - сначала ты создаешь файл с текущими метаданными, затем редактируешь его и применяешь данные к
файлам, запустив программу с флагом `-p` или `--parse`.

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

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

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

AUTHOR = 'Dan Sazonov'
Expand Down Expand Up @@ -42,12 +42,16 @@
# if True, the data entered by user won't be validated
SKIP_VALIDATION = False

# in 'min-scan' mode, data from the output is copied to the clipboard if True
DO_OUTPUT_COPY = True


class ColorMethods:
def __init__(self):
colorama.init()
self.reset = colorama.Style.RESET_ALL
self.red = colorama.Fore.RED
self.green = colorama.Fore.GREEN
self.bright = colorama.Style.BRIGHT
self.dim = colorama.Style.DIM

reset = colorama.Style.RESET_ALL
red = colorama.Fore.RED
green = colorama.Fore.GREEN
bright = colorama.Style.BRIGHT
dim = colorama.Style.DIM
27 changes: 23 additions & 4 deletions features.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,22 @@ def get_track_title(track: EasyID3) -> list[str, str]:
return clip


def get_title_pairs(track: EasyID3) -> str:
def get_title_pairs(all_log: list, do_copy: bool) -> str:
"""
Get nice string from the data of file
:param track: mutagen object, metadata of this track
:param all_log: list of mutagen object, metadata of this track
:param do_copy: output will be added to the clipboard, if this True
:return: "artist - title"
"""
track_title = get_track_title(track)
return f'{track_title[0]} - {track_title[1]}'
out = ''
for track in all_log:
track_title = get_track_title(track)
out += f'{track_title[0]} - {track_title[1]}\n'

if do_copy:
pyperclip.copy(out)
return out


def copy_track_title(track: EasyID3) -> None:
Expand Down Expand Up @@ -108,3 +115,15 @@ def read_json(file_name: str) -> dict:

with open(file_name, 'r', encoding='utf-8') as read_file:
return json.load(read_file)

# def get_min_log(track: EasyID3, do_copy=False) -> str:
# """
# Get nice string from the data of file
#
# :param track: mutagen object, metadata of this track
# :return: "artist - title"
# """
#
# out = get_title_pairs(tmp_log)
# pyperclip.copy(out)
# return out
7 changes: 6 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def main():
:return: None
"""
logger.create_log()
_all_log = []

# set the local variables
mp3_files, path = select_files()
Expand All @@ -200,7 +201,11 @@ def main():

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

if cli.min_scan:
out = features.get_title_pairs(_all_log, config.DO_OUTPUT_COPY)
print(out)

if cli.parse_mode:
logger.parse_log()
Expand Down
10 changes: 5 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
colorama==0.4.5
mutagen==1.45.1
colorama==0.4.6
mutagen==1.47.0
pyperclip~=1.8.2

requests~=2.28.1
beautifulsoup4~=4.11.1
deep_translator~=1.8.3
requests~=2.31.0
beautifulsoup4==4.12.2
deep_translator==1.11.4
Unidecode~=1.3.6
4 changes: 2 additions & 2 deletions scrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def _has_cyrillic(text: str) -> bool:
Checking for Cyrillic characters in a string
:param text: the string being checked
:return: True, if has Cyrillic
:return: True, if it has Cyrillic
"""
return bool(re.search('[\u0400-\u04FF]', text))

Expand All @@ -33,7 +33,7 @@ def get_album_title(artist, track):
Parse genius.com and return album title. 'Artist' and 'track' will be validated and translated to English
:param artist: name of the artist
:param track: track title
:param track: title of the track
:return: title of the album
"""
data = validate_for_url((_translate(artist), _translate(track)))
Expand Down

0 comments on commit 93cbd8d

Please sign in to comment.