Skip to content

Commit

Permalink
Merge branch 'master' into remove-dark-mode-preference
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbende committed Apr 28, 2024
2 parents 83f18f8 + e1922c3 commit 5b3e680
Show file tree
Hide file tree
Showing 164 changed files with 6,837 additions and 15,821 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "monthly"
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
with:
args: --exit-zero
args: --output-format github
2 changes: 1 addition & 1 deletion .github/workflows/flatpak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
# Don't fail the whole workflow if one architecture fails
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install deps
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ debian/debhelper-build-stamp
debian/files
peewee/
venv/
env/
blueprint-compiler/

.pytest_cache

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,12 @@ See [DEVELOPMENT.md](DEVELOPMENT.md) for detailed instructions and developing Co
- `python3`
- `meson >= 0.40.0` as build system
- `gtk4 >= 4.10`
- `libadwaita >= 1.4.0`
- `libadwaita >= 1.5.0`
- `peewee >= 3.9.6` as object relation mapper
- `mutagen` for meta tag management
- `distro`
- `requests`
- `pytz`
- `packaging`
- `gi-cairo`
- `gst-1.0`
- `file`
Expand Down
69 changes: 31 additions & 38 deletions com.github.geigi.cozy.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"app-id": "com.github.geigi.cozy",
"runtime": "org.gnome.Platform",
"runtime-version": "45",
"runtime-version": "46",
"sdk": "org.gnome.Sdk",
"command": "com.github.geigi.cozy",
"finish-args": [
Expand Down Expand Up @@ -30,8 +30,8 @@
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/e1/54/d08d1ad53788515392bec14d2d6e8c410bffdc127780a9a4aa8e6854d502/distro-1.7.0-py3-none-any.whl",
"sha256": "d596311d707e692c2160c37807f83e3820c5d539d5a83e87cfb6babd8ba3a06b"
"url": "https://files.pythonhosted.org/packages/12/b3/231ffd4ab1fc9d679809f356cebee130ac7daa00d6d6f3206dd4fd137e9e/distro-1.9.0-py3-none-any.whl",
"sha256": "7bffd925d65168f85027d8da9af6bddab658135b840670a223589bc0c8ef02b2"
}
]
},
Expand All @@ -44,27 +44,8 @@
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/16/b3/f7aa8edf2ff4495116f95fd442b2a346aa55d1d46313143c8814886dbcdb/mutagen-1.45.1-py3-none-any.whl",
"sha256": "9c9f243fcec7f410f138cb12c21c84c64fde4195481a30c9bfb05b5f003adfed"
}
]
},
{
"name": "python3-packaging",
"buildsystem": "simple",
"build-commands": [
"pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"packaging\" --no-build-isolation"
],
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/05/8e/8de486cbd03baba4deef4142bd643a3e7bbe954a784dc1bb17142572d127/packaging-21.3-py3-none-any.whl",
"sha256": "ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/6c/10/a7d0fa5baea8fe7b50f448ab742f26f52b80bfca85ac2be9d35cdd9a3246/pyparsing-3.0.9-py3-none-any.whl",
"sha256": "5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"
"url": "https://files.pythonhosted.org/packages/b0/7a/620f945b96be1f6ee357d211d5bf74ab1b7fe72a9f1525aafbfe3aee6875/mutagen-1.47.0-py3-none-any.whl",
"sha256": "edd96f50c5907a9539d8e5bba7245f62c9f520aef333d13392a79a4f70aca719"
}
]
},
Expand All @@ -77,8 +58,8 @@
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/45/c4/be139f7b7e0bbbc7b2fba4dc492cfb0202c64a0086fa2d23c0b6091ef4f2/peewee-3.15.1.tar.gz",
"sha256": "6d5db3babc33819ac326f1550e5a39677f4584094c567a7b88cc6bf7bcdcb687"
"url": "https://files.pythonhosted.org/packages/8d/a5/89cdbc4a7f6d7a0624c120be102db770ee717aa371066581e3daf2beb96f/peewee-3.17.1.tar.gz",
"sha256": "e009ac4227c4fdc0058a56e822ad5987684f0a1fbb20fed577200785102581c3"
}
]
},
Expand All @@ -91,8 +72,8 @@
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/60/2e/dec1cc18c51b8df33c7c4d0a321b084cf38e1733b98f9d15018880fb4970/pytz-2022.1-py2.py3-none-any.whl",
"sha256": "e68985985296d9a66a881eb3193b0906246245294a881e7c8afe623866ac6a5c"
"url": "https://files.pythonhosted.org/packages/9c/3d/a121f284241f08268b21359bd425f7d4825cffc5ac5cd0e1b3d82ffd2b10/pytz-2024.1-py2.py3-none-any.whl",
"sha256": "328171f4e3623139da4983451950b28e95ac706e13f3f2630a879749e7a8b319"
}
]
},
Expand All @@ -105,28 +86,40 @@
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/94/69/64b11e8c2fb21f08634468caef885112e682b0ebe2908e74d3616eb1c113/charset_normalizer-2.1.0-py3-none-any.whl",
"sha256": "5189b6f22b01957427f35b6a08d9a0bc45b46d3788ef5a92e978433c7a35f8a5"
"url": "https://files.pythonhosted.org/packages/ba/06/a07f096c664aeb9f01624f858c3add0a4e913d6c96257acb4fce61e7de14/certifi-2024.2.2-py3-none-any.whl",
"sha256": "dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/ca/91/6d9b8ccacd0412c08820f72cebaa4f0c0441b5cda699c90f618b6f8a1b42/requests-2.28.1-py3-none-any.whl",
"sha256": "8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349"
"url": "https://files.pythonhosted.org/packages/63/09/c1bc53dab74b1816a00d8d030de5bf98f724c52c1635e07681d312f20be8/charset-normalizer-3.3.2.tar.gz",
"sha256": "f30c3cb33b24454a82faecaf01b19c18562b1e89558fb6c56de4d9118a032fd5"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/d1/cb/4783c8f1a90f89e260dbf72ebbcf25931f3a28f8f80e2e90f8a589941b19/urllib3-1.26.11-py2.py3-none-any.whl",
"sha256": "c33ccba33c819596124764c23a97d25f32b28433ba0dedeb77d873a38722c9bc"
"url": "https://files.pythonhosted.org/packages/c2/e7/a82b05cf63a603df6e68d59ae6a68bf5064484a0718ea5033660af4b54a9/idna-3.6-py3-none-any.whl",
"sha256": "c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/04/a2/d918dcd22354d8958fe113e1a3630137e0fc8b44859ade3063982eacd2a4/idna-3.3-py3-none-any.whl",
"sha256": "84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff"
"url": "https://files.pythonhosted.org/packages/70/8e/0e2d847013cb52cd35b38c009bb167a1a26b2ce6cd6965bf26b47bc0bf44/requests-2.31.0-py3-none-any.whl",
"sha256": "58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/e9/06/d3d367b7af6305b16f0d28ae2aaeb86154fa91f144f036c2d5002a5a202b/certifi-2022.6.15-py3-none-any.whl",
"sha256": "fe86415d55e84719d75f8b69414f6438ac3547d2078ab91b67e779ef69378412"
"url": "https://files.pythonhosted.org/packages/88/75/311454fd3317aefe18415f04568edc20218453b709c63c58b9292c71be17/urllib3-2.2.0-py3-none-any.whl",
"sha256": "ce3711610ddce217e6d113a2732fafad960a03fd0318c91faa79481e35c11224"
}
]
},
{
"name": "blueprint-compiler",
"buildsystem": "meson",
"cleanup": [ "*" ],
"sources": [
{
"type": "git",
"url": "https://gitlab.gnome.org/jwestman/blueprint-compiler.git",
"tag": "v0.10.0"
}
]
},
Expand Down
26 changes: 11 additions & 15 deletions cozy/app_controller.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
from gi.repository import Gio

import cozy.ext.inject as inject
from peewee import SqliteDatabase

from cozy.control.offline_cache import OfflineCache
from cozy.media.files import Files
from cozy.media.gst_player import GstPlayer
from cozy.media.player import Player
from cozy.model.database_importer import DatabaseImporter
from cozy.power_manager import PowerManager
from cozy.report import reporter
import cozy.ext.inject as inject
from cozy.application_settings import ApplicationSettings
from cozy.architecture.singleton import Singleton
from cozy.control.db import get_db
from cozy.control.filesystem_monitor import FilesystemMonitor
from cozy.control.offline_cache import OfflineCache
from cozy.media.files import Files
from cozy.media.gst_player import GstPlayer
from cozy.media.player import Player
from cozy.model.book import Book
from cozy.model.database_importer import DatabaseImporter
from cozy.model.library import Library
from cozy.model.settings import Settings
from cozy.open_view import OpenView
from cozy.power_manager import PowerManager
from cozy.report import reporter
from cozy.ui.app_view import AppView
from cozy.ui.book_detail_view import BookDetailView
from cozy.ui.headerbar import Headerbar
from cozy.ui.toaster import ToastNotifier
from cozy.ui.library_view import LibraryView
from cozy.ui.main_view import CozyUI
from cozy.ui.media_controller import MediaController
from cozy.ui.search_view import SearchView
from cozy.ui.widgets.whats_new_window import WhatsNewWindow
from cozy.ui.toaster import ToastNotifier
from cozy.view import View
from cozy.view_model.app_view_model import AppViewModel
from cozy.view_model.book_detail_view_model import BookDetailViewModel
from cozy.view_model.headerbar_view_model import HeaderbarViewModel
from cozy.view_model.library_view_model import LibraryViewModel, LibraryViewMode
from cozy.view_model.library_view_model import LibraryViewMode, LibraryViewModel
from cozy.view_model.playback_control_view_model import PlaybackControlViewModel
from cozy.view_model.playback_speed_view_model import PlaybackSpeedViewModel
from cozy.view_model.search_view_model import SearchViewModel
Expand All @@ -50,11 +48,9 @@ def __init__(self, gtk_app, main_window_builder, main_window):

reporter.info("main", "startup")

self.whats_new_window: WhatsNewWindow = WhatsNewWindow()

self.library_view: LibraryView = LibraryView(main_window_builder)
self.app_view: AppView = AppView(main_window_builder)
self.headerbar: Headerbar = Headerbar(main_window_builder)
self.library_view: LibraryView = LibraryView(main_window_builder)
self.book_detail_view: BookDetailView = BookDetailView(main_window_builder)
self.media_controller: MediaController = MediaController(main_window_builder)
self.search_view: SearchView = SearchView(main_window_builder, self.headerbar)
Expand Down
16 changes: 7 additions & 9 deletions cozy/application.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
import os
import platform
import sys
import threading
Expand Down Expand Up @@ -39,10 +38,10 @@ def __init__(self, pkgdatadir: str):

def do_startup(self):
log.info(distro.linux_distribution(full_distribution_name=False))
log.info(f"Starting up cozy {__version__}")
log.info(f"libadwaita version: {Adw._version}")
log.info("Starting up cozy %s", __version__)
log.info("libadwaita version: %s", Adw._version)

self.ui = CozyUI(self.pkgdatadir, self, __version__)
self.ui = CozyUI(self, __version__)
Adw.Application.do_startup(self)
init_db()
self.ui.startup()
Expand All @@ -56,10 +55,9 @@ def do_activate(self):
if Settings.get().first_start:
Settings.update(first_start=False).execute()

path = os.path.join(Path.home(), _("Audiobooks"))
Storage.create(path=path, default=True)

os.makedirs(path, exist_ok=True)
audiobooks_path = Path.home() / _("Audiobooks")
audiobooks_path.mkdir(exist_ok=True)
Storage.create(path=str(audiobooks_path), default=True)

self.add_window(self.ui.window)

Expand All @@ -82,7 +80,7 @@ def handle_exception(self, _):

def quit(self):
self.app_controller.quit()
super(Application, self).quit()
super().quit()

@staticmethod
def init_custom_widgets():
Expand Down
5 changes: 2 additions & 3 deletions cozy/architecture/event_sender.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from typing import List, Callable
from typing import Callable

import gi
from gi.repository import GLib


class EventSender:
_listeners: List[Callable]
_listeners: list[Callable]

def __init__(self):
self._listeners = []
Expand Down
2 changes: 1 addition & 1 deletion cozy/architecture/observable.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import logging
from typing import Callable

from gi.repository import GLib

from cozy.report import reporter
import logging

log = logging.getLogger("observable")

Expand Down
6 changes: 3 additions & 3 deletions cozy/architecture/profiler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import time
import logging
import functools
import logging
import time

log = logging.getLogger("timing")

Expand All @@ -10,7 +10,7 @@ def wrap(*args):
time1 = time.perf_counter()
ret = f(*args)
time2 = time.perf_counter()
log.info('{:s} function took {:.3f} ms'.format(f.__name__, (time2-time1)*1000.0))
log.info('%s function took %.3f ms', f.__name__, (time2-time1)*1000.0)

return ret
return wrap
2 changes: 1 addition & 1 deletion cozy/architecture/singleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ class Singleton(type):
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
cls._instances[cls] = super().__call__(*args, **kwargs)
return cls._instances[cls]

21 changes: 7 additions & 14 deletions cozy/control/artwork_cache.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import os
import uuid
import logging

from gi.repository import Gdk, GdkPixbuf

Expand Down Expand Up @@ -55,8 +55,7 @@ def delete_artwork_cache(self):
q.execute()

def _on_importer_event(self, event, data):
if event == "scan":
if data == ScanStatus.STARTED:
if event == "scan" and data == ScanStatus.STARTED:
self.delete_artwork_cache()

def _create_artwork_cache(self, book, pixbuf, size):
Expand Down Expand Up @@ -88,8 +87,7 @@ def _create_artwork_cache(self, book, pixbuf, size):
resized_pixbuf.savev(file_path, "jpeg", ["quality", None], ["95"])
except Exception as e:
reporter.warning("artwork_cache", "Failed to save resized cache albumart")
log.warning("Failed to save resized cache albumart for following uuid: " + gen_uuid)
log.warning(e)
log.warning("Failed to save resized cache albumart for uuid %r: %s", gen_uuid, e)

return resized_pixbuf

Expand All @@ -98,7 +96,7 @@ def get_album_art_path(self, book, size):
if query.exists():
try:
uuid = query.first().uuid
except Exception as e:
except Exception:
reporter.error("artwork_cache", "load_pixbuf_from_cache: query exists but query.first().uuid crashed.")
return None
else:
Expand All @@ -124,10 +122,7 @@ def _load_pixbuf_from_cache(self, book, size):
path = self.get_album_art_path(book, size)

try:
if path:
pixbuf = GdkPixbuf.Pixbuf.new_from_file(path)
else:
pixbuf = None
pixbuf = GdkPixbuf.Pixbuf.new_from_file(path) if path else None
except Exception as e:
log.warning("Failed to load pixbuf from path: %s. Deleting file.", path)
log.debug(e)
Expand Down Expand Up @@ -170,8 +165,7 @@ def _load_pixbuf_from_db(self, book):
pixbuf = loader.get_pixbuf()
except Exception as e:
reporter.warning("artwork_cache", "Could not get book cover from db.")
log.warning("Could not get cover for book " + book.name)
log.warning(e)
log.warning("Could not get cover for book %r: %s", book.name, e)

return pixbuf

Expand Down Expand Up @@ -209,8 +203,7 @@ def _load_pixbuf_from_file(self, book):
cover_files = [f for f in os.listdir(directory)
if f.lower().endswith('.png') or f.lower().endswith(".jpg") or f.lower().endswith(".gif")]
except Exception as e:
log.warning("Could not open audiobook directory and look for cover files.")
log.warning(e)
log.warning("Could not open audiobook directory and look for cover files: %s", e)
for elem in (x for x in cover_files if os.path.splitext(x.lower())[0] == "cover"):
# find cover.[jpg,png,gif]
try:
Expand Down
Loading

0 comments on commit 5b3e680

Please sign in to comment.