Add option to sort by last modification date (close #88)
Store the metadate “last-modified” for a track and an album and add an option sort by it.
This commit is contained in:
parent
5618c9016c
commit
8607bf15a9
10 changed files with 84 additions and 26 deletions
|
@ -129,6 +129,22 @@
|
|||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="sort_modified">
|
||||
<property name="label" translatable="yes">sort by modification</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">False</property>
|
||||
<property name="draw-indicator">True</property>
|
||||
<property name="group">sort_year</property>
|
||||
<signal name="toggled" handler="on_sort_toggled" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="toolbar_sort_order_button">
|
||||
<property name="label">gtk-sort-descending</property>
|
||||
|
@ -143,7 +159,7 @@
|
|||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">5</property>
|
||||
<property name="position">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<value nick="artist" value="0" />
|
||||
<value nick="title" value="1" />
|
||||
<value nick="year" value="2" />
|
||||
<value nick="modified" value="3" />
|
||||
</enum>
|
||||
<schema path="/xyz/suruatoel/mcg/" id="xyz.suruatoel.mcg" gettext-domain="mcg">
|
||||
<key type="s" name="host">
|
||||
|
|
BIN
po/de.mo
BIN
po/de.mo
Binary file not shown.
22
po/de.po
22
po/de.po
|
@ -2,17 +2,17 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: CoverGrid (mcg)\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-09-05 15:08+0200\n"
|
||||
"PO-Revision-Date: 2020-10-24 14:41+0200\n"
|
||||
"POT-Creation-Date: 2023-01-08 19:06+0100\n"
|
||||
"PO-Revision-Date: 2023-01-08 19:07+0100\n"
|
||||
"Last-Translator: coderkun <olli@suruatoel.xyz>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: de_DE\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 2.4.1\n"
|
||||
"X-Poedit-Basepath: ../../..\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Generator: Poedit 3.2.2\n"
|
||||
"X-Poedit-Basepath: ../../..\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\n"
|
||||
|
||||
#: data/xyz.suruatoel.mcg.gschema.xml:11
|
||||
|
@ -216,15 +216,19 @@ msgstr "nach Titel"
|
|||
msgid "sort by year"
|
||||
msgstr "nach Jahr"
|
||||
|
||||
#: data/ui/library-toolbar.ui:169 data/ui/shortcuts-dialog.ui:115
|
||||
#: data/ui/library-toolbar.ui:134
|
||||
msgid "sort by modification"
|
||||
msgstr "nach Änderungsdatum"
|
||||
|
||||
#: data/ui/library-toolbar.ui:185 data/ui/shortcuts-dialog.ui:115
|
||||
msgid "Search the library"
|
||||
msgstr "Die Bibliothek durchsuchen"
|
||||
|
||||
#: data/ui/library-toolbar.ui:192 data/ui/playlist-toolbar.ui:15
|
||||
#: data/ui/library-toolbar.ui:208 data/ui/playlist-toolbar.ui:15
|
||||
msgid "Select multiple albums"
|
||||
msgstr "Mehrere Alben auswählen"
|
||||
|
||||
#: data/ui/library-toolbar.ui:214
|
||||
#: data/ui/library-toolbar.ui:230
|
||||
msgid "Settings and actions"
|
||||
msgstr "Einstellungen und Aktionen"
|
||||
|
||||
|
@ -353,11 +357,11 @@ msgstr "Zu MPD verbinden"
|
|||
msgid "Adjust the volume"
|
||||
msgstr "Die Lautstärke anpassen"
|
||||
|
||||
#: src/librarypanel.py:419
|
||||
#: src/librarypanel.py:421
|
||||
msgid "Loading albums"
|
||||
msgstr "Alben werden geladen"
|
||||
|
||||
#: src/librarypanel.py:519
|
||||
#: src/librarypanel.py:521
|
||||
msgid "Loading images"
|
||||
msgstr "Bilder werden geladen"
|
||||
|
||||
|
|
BIN
po/en.mo
BIN
po/en.mo
Binary file not shown.
22
po/en.po
22
po/en.po
|
@ -2,17 +2,17 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: CoverGrid (mcg)\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-09-05 15:08+0200\n"
|
||||
"PO-Revision-Date: 2020-10-24 14:40+0200\n"
|
||||
"POT-Creation-Date: 2023-01-08 19:06+0100\n"
|
||||
"PO-Revision-Date: 2023-01-08 19:07+0100\n"
|
||||
"Last-Translator: coderkun <olli@suruatoel.xyz>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: en\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 2.4.1\n"
|
||||
"X-Poedit-Basepath: ../../..\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Generator: Poedit 3.2.2\n"
|
||||
"X-Poedit-Basepath: ../../..\n"
|
||||
"X-Poedit-SearchPath-0: mcg\n"
|
||||
"X-Poedit-SearchPath-1: data/ui\n"
|
||||
|
||||
|
@ -217,15 +217,19 @@ msgstr "by Title"
|
|||
msgid "sort by year"
|
||||
msgstr "by Year"
|
||||
|
||||
#: data/ui/library-toolbar.ui:169 data/ui/shortcuts-dialog.ui:115
|
||||
#: data/ui/library-toolbar.ui:134
|
||||
msgid "sort by modification"
|
||||
msgstr "by Modification Date"
|
||||
|
||||
#: data/ui/library-toolbar.ui:185 data/ui/shortcuts-dialog.ui:115
|
||||
msgid "Search the library"
|
||||
msgstr "Search the library"
|
||||
|
||||
#: data/ui/library-toolbar.ui:192 data/ui/playlist-toolbar.ui:15
|
||||
#: data/ui/library-toolbar.ui:208 data/ui/playlist-toolbar.ui:15
|
||||
msgid "Select multiple albums"
|
||||
msgstr "Select multiple albums"
|
||||
|
||||
#: data/ui/library-toolbar.ui:214
|
||||
#: data/ui/library-toolbar.ui:230
|
||||
msgid "Settings and actions"
|
||||
msgstr "Settings and actions"
|
||||
|
||||
|
@ -354,11 +358,11 @@ msgstr "Connect to MPD"
|
|||
msgid "Adjust the volume"
|
||||
msgstr "Adjust the volume"
|
||||
|
||||
#: src/librarypanel.py:419
|
||||
#: src/librarypanel.py:421
|
||||
msgid "Loading albums"
|
||||
msgstr "Loading albums"
|
||||
|
||||
#: src/librarypanel.py:519
|
||||
#: src/librarypanel.py:521
|
||||
msgid "Loading images"
|
||||
msgstr "Loading images"
|
||||
|
||||
|
|
16
po/mcg.pot
16
po/mcg.pot
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: mcg\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-09-05 15:08+0200\n"
|
||||
"POT-Creation-Date: 2023-01-08 19:06+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -215,15 +215,19 @@ msgstr ""
|
|||
msgid "sort by year"
|
||||
msgstr ""
|
||||
|
||||
#: data/ui/library-toolbar.ui:169 data/ui/shortcuts-dialog.ui:115
|
||||
#: data/ui/library-toolbar.ui:134
|
||||
msgid "sort by modification"
|
||||
msgstr ""
|
||||
|
||||
#: data/ui/library-toolbar.ui:185 data/ui/shortcuts-dialog.ui:115
|
||||
msgid "Search the library"
|
||||
msgstr ""
|
||||
|
||||
#: data/ui/library-toolbar.ui:192 data/ui/playlist-toolbar.ui:15
|
||||
#: data/ui/library-toolbar.ui:208 data/ui/playlist-toolbar.ui:15
|
||||
msgid "Select multiple albums"
|
||||
msgstr ""
|
||||
|
||||
#: data/ui/library-toolbar.ui:214
|
||||
#: data/ui/library-toolbar.ui:230
|
||||
msgid "Settings and actions"
|
||||
msgstr ""
|
||||
|
||||
|
@ -352,11 +356,11 @@ msgstr ""
|
|||
msgid "Adjust the volume"
|
||||
msgstr ""
|
||||
|
||||
#: src/librarypanel.py:419
|
||||
#: src/librarypanel.py:421
|
||||
msgid "Loading albums"
|
||||
msgstr ""
|
||||
|
||||
#: src/librarypanel.py:519
|
||||
#: src/librarypanel.py:521
|
||||
msgid "Loading images"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
import concurrent.futures
|
||||
import configparser
|
||||
import dateutil.parser
|
||||
import logging
|
||||
import os
|
||||
import queue
|
||||
|
@ -937,6 +938,8 @@ class Client(Base):
|
|||
track.set_date(song['date'])
|
||||
if 'albumartist' in song:
|
||||
track.set_albumartists(song['albumartist'])
|
||||
if 'last-modified' in song:
|
||||
track.set_last_modified(song['last-modified'])
|
||||
return track
|
||||
|
||||
|
||||
|
@ -998,6 +1001,7 @@ class MCGAlbum:
|
|||
self._host = host
|
||||
self._tracks = []
|
||||
self._length = 0
|
||||
self._last_modified = None
|
||||
self._id = Utils.generate_id(title)
|
||||
|
||||
|
||||
|
@ -1057,6 +1061,9 @@ class MCGAlbum:
|
|||
path = os.path.dirname(track.get_file())
|
||||
if path not in self._pathes:
|
||||
self._pathes.append(path)
|
||||
if track.get_last_modified():
|
||||
if not self._last_modified or track.get_last_modified() > self._last_modified:
|
||||
self._last_modified = track.get_last_modified()
|
||||
|
||||
|
||||
def get_tracks(self):
|
||||
|
@ -1067,6 +1074,10 @@ class MCGAlbum:
|
|||
return self._length
|
||||
|
||||
|
||||
def get_last_modified(self):
|
||||
return self._last_modified
|
||||
|
||||
|
||||
def filter(self, filter_string):
|
||||
if len(filter_string) == 0:
|
||||
return True
|
||||
|
@ -1102,6 +1113,8 @@ class MCGAlbum:
|
|||
value_function = "get_title"
|
||||
elif criterion == SortOrder.YEAR:
|
||||
value_function = "get_date"
|
||||
elif criterion == SortOrder.MODIFIED:
|
||||
value_function = "get_last_modified"
|
||||
|
||||
value1 = getattr(album1, value_function)()
|
||||
value2 = getattr(album2, value_function)()
|
||||
|
@ -1137,6 +1150,7 @@ class MCGTrack:
|
|||
self._track = None
|
||||
self._length = 0
|
||||
self._date = None
|
||||
self._last_modified = None
|
||||
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -1208,6 +1222,18 @@ class MCGTrack:
|
|||
return self._file
|
||||
|
||||
|
||||
def set_last_modified(self, date_string):
|
||||
if date_string:
|
||||
try:
|
||||
self._last_modified = dateutil.parser.isoparse(date_string)
|
||||
except ValueError as e:
|
||||
self._logger.debug("Invalid date format: %s", date_string)
|
||||
|
||||
|
||||
def get_last_modified(self):
|
||||
return self._last_modified
|
||||
|
||||
|
||||
|
||||
|
||||
class MCGPlaylistTrack(MCGTrack):
|
||||
|
|
|
@ -39,6 +39,7 @@ class LibraryToolbar(Gtk.ButtonBox):
|
|||
sort_artist = Gtk.Template.Child()
|
||||
sort_title = Gtk.Template.Child()
|
||||
sort_year = Gtk.Template.Child()
|
||||
sort_modified = Gtk.Template.Child()
|
||||
grid_scale = Gtk.Template.Child()
|
||||
|
||||
|
||||
|
@ -50,7 +51,8 @@ class LibraryToolbar(Gtk.ButtonBox):
|
|||
self._toolbar_sort_buttons = {
|
||||
SortOrder.ARTIST: self.sort_artist,
|
||||
SortOrder.TITLE: self.sort_title,
|
||||
SortOrder.YEAR: self.sort_year
|
||||
SortOrder.YEAR: self.sort_year,
|
||||
SortOrder.MODIFIED: self.sort_modified
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -86,3 +86,4 @@ class SortOrder:
|
|||
ARTIST = 0
|
||||
TITLE = 1
|
||||
YEAR = 2
|
||||
MODIFIED = 3
|
||||
|
|
Loading…
Reference in a new issue