[gnome-music/wip/merge: 250/343] Use getMediaTitle where possible
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/merge: 250/343] Use getMediaTitle where possible
- Date: Thu, 25 Jul 2013 11:33:39 +0000 (UTC)
commit f1dd0d331314b86546e6f3b1afd448c671b628c5
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date: Thu Jul 18 11:51:16 2013 +0200
Use getMediaTitle where possible
gnomemusic/player.py | 11 ++---------
gnomemusic/view.py | 18 ++++++------------
gnomemusic/widgets.py | 11 ++++++-----
3 files changed, 14 insertions(+), 26 deletions(-)
---
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 3d9ea10..a5ba50f 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -253,14 +253,7 @@ class Player(GObject.GObject):
self.coverImg.set_from_pixbuf(self._symbolicIcon)
self.cache.lookup(ART_SIZE, media.get_artist(), media.get_string(Grl.METADATA_KEY_ALBUM),
self._on_cache_lookup)
- if media.get_title() is not None:
- self.titleLabel.set_label(media.get_title())
- else:
- url = media.get_url(),
- filename = GLib.File.new_for_path(url),
- basename = filename.get_basename(),
- toShow = GLib.Uri.unescape_string(basename, None)
- self.titleLabel.set_label(toShow)
+ self.titleLabel.set_label(AlbumArtCache.getMediaTitle(media))
if media.get_artist() is not None:
self.artistLabel.set_label(media.get_artist())
@@ -603,7 +596,7 @@ class Player(GObject.GObject):
'xesam:userRating': GLib.Variant.new('d', media.get_rating()),
}
- title = media.get_title()
+ title = AlbumArtCache.getMediaTitle(media)
if title:
metadata['xesam:title'] = GLib.Variant.new('s', title)
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index ff10702..749ad25 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -13,11 +13,6 @@ from gnomemusic.albumArtCache import AlbumArtCache as albumArtCache
tracker = Tracker.SparqlConnection.get(None)
-def extractFileName(uri):
- exp = "^.*[\\\/]|[.][^.]*$"
- return uri.replace(exp, '')
-
-
class ViewContainer(Gtk.Stack):
nowPlayingIconName = 'media-playback-start-symbolic'
errorIconName = 'dialog-error-symbolic'
@@ -176,21 +171,21 @@ class ViewContainer(Gtk.Stack):
artist = item.get_author()
if item.get_string(Grl.METADATA_KEY_ARTIST) is not None:
artist = item.get_string(Grl.METADATA_KEY_ARTIST)
- if (item.get_title() is None) and (item.get_url() is not None):
- item.set_title(extractFileName(item.get_url()))
+ title = albumArtCache.getMediaTitle(item)
+ item.set_title(title)
try:
if item.get_url():
self.player.discoverer.discover_uri(item.get_url())
self._model.set(iter,
[0, 1, 2, 3, 4, 5, 7, 8, 9, 10],
- [str(item.get_id()), "", item.get_title(),
+ [str(item.get_id()), "", title,
artist, self._symbolicIcon, item,
-1, self.nowPlayingIconName, False, False])
except:
print("failed to discover url " + item.get_url())
self._model.set(iter,
[0, 1, 2, 3, 4, 5, 7, 8, 9, 10],
- [str(item.get_id()), "", item.get_title(),
+ [str(item.get_id()), "", title,
artist, self._symbolicIcon, item,
-1, self.errorIconName, False, True])
GLib.idle_add(self._update_album_art, item, iter)
@@ -306,8 +301,7 @@ class Songs(ViewContainer):
if item is not None:
self._offset += 1
iter = self._model.append()
- if (item.get_title() is None) and (item.get_url() is not None):
- item.set_title(extractFileName(item.get_url()))
+ item.set_title(albumArtCache.getMediaTitle(item))
try:
if item.get_url():
self.player.discoverer.discover_uri(item.get_url())
@@ -371,7 +365,7 @@ class Songs(ViewContainer):
cell.set_property("yalign", 0.5)
cell.set_property("height", 48)
cell.set_property("ellipsize", Pango.EllipsizeMode.END)
- cell.set_property("text", item.get_title())
+ cell.set_property("text", albumArtCache.getMediaTitle(item))
def _on_list_widget_star_render(self, col, cell, model, itr, data):
showstar = model.get_value(itr, 9)
diff --git a/gnomemusic/widgets.py b/gnomemusic/widgets.py
index 38a21c4..4a0af3e 100644
--- a/gnomemusic/widgets.py
+++ b/gnomemusic/widgets.py
@@ -110,7 +110,8 @@ class AlbumWidget(Gtk.EventBox):
if(self.model.get_value(iter, 7) != ERROR_ICON_NAME):
if (self.iterToClean and self.player.playlistId == self.album):
item = self.model.get_value(self.iterToClean, 5)
- self.model.set_value(self.iterToClean, 0, item.get_title())
+ title = AlbumArtCache.getMediaTitle(media)
+ self.model.set_value(self.iterToClean, 0, title)
#Hide now playing icon
self.model.set_value(self.iterToClean, 6, False)
self.player.set_playlist("Album", self.album, self.model, iter, 5)
@@ -498,8 +499,8 @@ class ArtistAlbumWidget(Gtk.HBox):
ui.get_object("num")\
.set_markup("<span color='grey'>%d</span>"
% len(self.songs))
- if track.get_title():
- ui.get_object("title").set_text(track.get_title())
+ title = AlbumArtCache.getMediaTitle(track)
+ ui.get_object("title").set_text(title)
ui.get_object("title").set_alignment(0.0, 0.5)
self.ui.get_object("grid1").attach(
song_widget,
@@ -516,7 +517,7 @@ class ArtistAlbumWidget(Gtk.HBox):
self.player.discoverer.discover_uri(track.get_url())
self.model.set(itr,
[0, 1, 2, 3, 4, 5],
- [track.get_title(), "", "", False,
+ [title, "", "", False,
NOW_PLAYING_ICON_NAME, track])
song_widget.now_playing_sign = ui.get_object("image1")
song_widget.now_playing_sign.set_from_icon_name(
@@ -531,7 +532,7 @@ class ArtistAlbumWidget(Gtk.HBox):
except:
print("failed to discover url " + track.get_url())
self.model.set(itr, [0, 1, 2, 3, 4, 5],
- [track.get_title(), "", "", True,
+ [title, "", "", True,
ERROR_ICON_NAME, track])
song_widget.now_playing_sign = ui.get_object("image1")
song_widget.now_playing_sign.set_from_icon_name(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]