Skip to content

Commit f9f7f27

Browse files
committed
added filename box in tag editor
1 parent d35d7b5 commit f9f7f27

File tree

3 files changed

+39
-19
lines changed

3 files changed

+39
-19
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
CHANGELOG
22
=========
33

4+
v0.7.0
5+
------
6+
7+
- [ ] Batch tag files
8+
- [ ] Customizable keybindings
9+
- [ ] Autocomplete in genre tag field
10+
- [x] Filename field in tag editing view
11+
- [ ] Short description of preferences option in status line
12+
- [x] Use `l` to invoke a search box for searching for files(`n` for next match, 'N' for previous match
13+
414
v0.6.3
515
------
616

clid/editmeta.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ def create(self):
4545
self.meta.album = '' # revert what was just done
4646
self.meta.write()
4747

48+
self.filenamebox = self.add(self.TEXTBOX, name='Filename',
49+
value=os.path.basename(self.file).replace('.mp3', ''))
50+
self.nextrely += 2
51+
4852
self.tit = self.add(self.TEXTBOX, name='Title', value=self.meta.title)
4953
self.nextrely += 1
5054
self.alb = self.add(self.TEXTBOX, name='Album', value=self.meta.album)
@@ -131,17 +135,15 @@ def on_ok(self): # char is for handlers
131135

132136
self.meta.write()
133137

134-
status_meta = '{art} - {alb} - {tno}. {title} '.format(
135-
art=self.meta.artist,
136-
alb=self.meta.album,
137-
tno=self.meta.track if self.meta.track != 0 else ' ',
138-
title=self.meta.title
139-
)
138+
new_filename = os.path.dirname(self.file) + '/' + self.filenamebox.value + '.mp3'
139+
if self.file != new_filename: # filename was changed
140+
os.rename(self.file, new_filename)
141+
140142
main_form = self.parentApp.getForm("MAIN")
141-
main_form.wStatus2.value = status_meta
143+
main_form.value.load_files_and_set_values()
142144

143-
# update the metadata cache(database.Mp3DataBase.meta_cache) with new tags
144-
main_form.value.meta_cache[os.path.basename(self.file)] = status_meta
145+
main_form.wMain.set_status(filename=os.path.basename(new_filename)) # show the new tags in the status line
146+
main_form.load_files()
145147

146148
self.editing = False
147149
self.parentApp.switchForm("MAIN")

clid/main.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,25 @@ def __init__(self, *args, **kwargs):
6565
super().__init__(*args, **kwargs)
6666
smooth = self.parent.parentApp.settings['smooth_scroll'] # is smooth scroll enabled ?
6767
self.slow_scroll = True if smooth == 'true' else False
68+
self.space_selected_values = [] # stores list of files which was selected for batch tagging using <Space>
6869

6970
def set_status(self, filename):
7071
"""Set the the value of self.parent.wStatus2 with metadata of file under cursor."""
7172
self.parent.wStatus2.value = self.parent.value.parse_meta_for_status(filename=filename)
73+
self.parent.display()
7274

7375
def get_selected(self):
76+
"""Return the name of file under the cursor line"""
7477
return self.values[self.cursor_line]
7578

7679
def set_up_handlers(self):
7780
super().set_up_handlers()
78-
self.handlers['u'] = self.h_reload_files
79-
self.handlers['2'] = self.h_switch_to_settings
80-
self.handlers[curses.ascii.ESC] = self.h_revert_escape
81+
self.handlers.update({
82+
'u': self.h_reload_files,
83+
'2': self.h_switch_to_settings,
84+
curses.ascii.SP: self.h_multi_select,
85+
curses.ascii.ESC: self.h_revert_escape,
86+
})
8187

8288

8389
def h_reload_files(self, char):
@@ -97,6 +103,12 @@ def h_revert_escape(self, char):
97103

98104
# TODO: make it faster
99105

106+
def filter_value(self, index):
107+
if self._filter in self.display_value(self.values[index]).lower(): # ignore case
108+
return True
109+
else:
110+
return False
111+
100112
def h_switch_to_settings(self, char):
101113
self.parent.parentApp.switchForm("SETTINGS")
102114

@@ -111,7 +123,6 @@ def h_cursor_line_down(self, char):
111123
if (self.cursor_line + 1) < len(self.values): # need to +1 as cursor_line is the index
112124
filename = self.values[self.cursor_line + 1]
113125
self.set_status(filename)
114-
self.parent.display()
115126

116127
super().h_cursor_line_down(char) # code has some returns in between
117128

@@ -123,26 +134,23 @@ def h_cursor_line_up(self, char):
123134

124135
if self.cursor_line -1 > 0:
125136
self.set_status(self.get_selected())
126-
self.parent.display()
127137

128138
def h_cursor_page_down(self, char):
129139
super().h_cursor_page_down(char)
130140
if self.cursor_line != -1: # -1 if there is nothing to display
131141
self.set_status(self.get_selected())
132-
self.parent.display()
133142

134143
def h_cursor_page_up(self, char):
135144
super().h_cursor_page_up(char)
136145
if self.cursor_line -1 > 0:
137146
self.set_status(self.get_selected())
138-
self.parent.display()
139147

140148
def h_select(self, char):
141-
self.parent.parentApp.current_file = self.parent.value.file_dict[self.values[self.cursor_line]]
149+
self.parent.parentApp.current_file = self.parent.value.file_dict[self.get_selected()]
142150
self.parent.parentApp.switchForm("EDIT")
143151

144-
# TODO: smooth scroll
145-
152+
def h_multi_select(self, char):
153+
pass
146154

147155
class ClidInterface(npy.FormMuttActiveTraditional):
148156
"""The main app with the ui.

0 commit comments

Comments
 (0)