~comcloudway/melon

e814f5024eb85e7916ec5da864d73b1b9bb20335 — Jakob Meier 6 months ago b6910cb
decode unicode when rendering AdaptiveFeedItems, viewing playlists or
channels
5 files changed, 25 insertions(+), 14 deletions(-)

M README.md
M melon/browse/channel.py
M melon/browse/playlist.py
M melon/widgets/feeditem.py
A requirements.txt
M README.md => README.md +1 -1
@@ 56,7 56,7 @@ Of course, you are welcome to send issues and pull requests via email as well:
- `py3-beautifulsoup4`
- `py3-lxml`
- `py3-requests`
- `py3-sqlite3`
- `py3-unidecode`
- `gtk4.0`
- `libadwaita`
- `webkit2gtk-6.0`

M melon/browse/channel.py => melon/browse/channel.py +4 -3
@@ 12,6 12,7 @@ from melon.widgets.preferencerow import PreferenceRow, PreferenceType, Preferenc
from melon.widgets.iconbutton import IconButton
from melon.models import get_app_settings
from melon.models import is_subscribed_to_channel, ensure_subscribed_to_channel, ensure_unsubscribed_from_channel
from unidecode import unidecode

class BrowseChannelScreen(Adw.NavigationPage):
    def fetch_page(self, page=1):


@@ 51,7 52,7 @@ class BrowseChannelScreen(Adw.NavigationPage):
        # obtain channel information
        channel = self.instance.get_channel_info(channel_id)
        self.channel = channel
        self.set_title(channel.name)
        self.set_title(unidecode(channel.name))

        self.header_bar = Adw.HeaderBar()
        self.external_btn = IconButton("","modem-symbolic")


@@ 65,8 66,8 @@ class BrowseChannelScreen(Adw.NavigationPage):
        self.scrollview = Gtk.ScrolledWindow()
        self.box = Adw.PreferencesPage()
        self.about = Adw.PreferencesGroup()
        self.about.set_title(channel.name.replace("&", "&"))
        self.about.set_description(channel.bio.replace("&", "&"))
        self.about.set_title(unidecode(channel.name).replace("&", "&"))
        self.about.set_description(unidecode(channel.bio).replace("&", "&"))

        self.results = None


M melon/browse/playlist.py => melon/browse/playlist.py +3 -2
@@ 3,6 3,7 @@ import gi
gi.require_version('Gtk', '4.0')
gi.require_version('Adw', '1')
from gi.repository import Gtk, Adw, Gio, Gdk, GLib
from unidecode import unidecode

from melon.servers.utils import get_server_instance, get_servers_list
from melon.servers.utils import pixbuf_from_url


@@ 51,8 52,8 @@ class BrowsePlaylistScreen(Adw.NavigationPage):
        self.scrollview = Gtk.ScrolledWindow()
        self.box = Adw.PreferencesPage()
        self.about = Adw.PreferencesGroup()
        self.about.set_title(self.playlist.title)
        self.about.set_description(self.playlist.description)
        self.about.set_title(unidecode(self.playlist.title))
        self.about.set_description(unidecode(self.playlist.description))

        bookmark_pref = Preference(
            "bookmark-playlist",

M melon/widgets/feeditem.py => melon/widgets/feeditem.py +13 -8
@@ 9,6 9,7 @@ from melon.widgets.iconbutton import IconButton
from melon.models import PlaylistWrapperType,PlaylistWrapper
import threading
from melon.background import queue
from unidecode import unidecode

class AdaptiveFeedItem(Adw.ActionRow):
    """


@@ 35,25 36,29 @@ class AdaptiveFeedItem(Adw.ActionRow):
        thumb_url = None
        if isinstance(resource, Video):
            thumb_url = resource.thumbnail
            self.set_title(resource.title.replace("&","&"))
            self.set_subtitle(resource.channel[0].replace("&","&"))
            self.set_title(unidecode(resource.title).replace("&","&"))
            self.set_subtitle(unidecode(resource.channel[0]).replace("&","&"))
            self.set_action_name("win.player")
        elif isinstance(resource, Playlist):
            thumb_url = resource.thumbnail
            self.set_title(resource.title.replace("&","&"))
            self.set_title(unidecode(resource.title).replace("&","&"))
            pad = ""
            if len(resource.description) > 80:
                pad = "..."
            sub = resource.description[:80] + pad
            # NOTE: this might be a bad idea
            # because it could possibly cut the unicode in half? I think?
            sub = unidecode(resource.description)[:80] + pad
            self.set_subtitle(sub.replace("&","&"))
            self.set_action_name("win.browse_playlist")
        elif isinstance(resource, Channel):
            thumb_url = resource.avatar
            self.set_title(resource.name.replace("&","&"))
            self.set_title(unidecode(resource.name).replace("&","&"))
            pad = ""
            if len(resource.bio) > 80:
                pad = "..."
            sub = resource.bio[:80] + pad
            # NOTE: this might be a bad idea
            # because it could possibly cut the unicode in half? I think?
            sub = unidecode(resource.bio)[:80] + pad
            self.set_subtitle(sub.replace("&","&"))
            self.set_action_name("win.browse_channel")
        self.preview = Adw.Avatar()


@@ 81,8 86,8 @@ class AdaptivePlaylistFeedItem(Adw.ActionRow):
        pixbuf = None
        if show_preview:
            pixbuf = pixbuf_from_url(playlist.inner.thumbnail)
        self.set_title(playlist.inner.title.replace("&","&"))
        self.set_subtitle(playlist.inner.description.replace("&","&"))
        self.set_title(unidecode(playlist.inner.title).replace("&","&"))
        self.set_subtitle(unidecode(playlist.inner.description).replace("&","&"))
        if playlist.type == PlaylistWrapperType.EXTERNAL:
            self.set_action_name("win.browse_playlist")
            self.set_action_target_value(

A requirements.txt => requirements.txt +4 -0
@@ 0,0 1,4 @@
beautifulsoup4
lxml
requests
Unidecode