Permalink
Browse files

Remote URLs support.

  • Loading branch information...
1 parent f16bf34 commit 8c60b4e393cee25825808df2d07182657ed25eb1 @tsufeki committed Jul 27, 2013
Showing with 261 additions and 150 deletions.
  1. +2 −1 doc/templates.md
  2. +11 −1 qygmy/browser.py
  3. +11 −0 qygmy/dialogs.py
  4. +3 −2 qygmy/formatter.py
  5. +9 −0 qygmy/lists.py
  6. +10 −4 qygmy/qygmy.py
  7. +176 −133 qygmy/translations/qygmy_pl.ts
  8. +16 −1 qygmy/ui/browser.ui
  9. +23 −8 qygmy/ui/main.ui
View
@@ -47,8 +47,9 @@ Exactly one of those is set to `1`.
- `%length%`: length of the song in seconds (see `$time()`).
- `%track%`, `%totaltracks%`, `%disc%`, `%totaldiscs%`
- `%lastmodified%`: last modification date.
+- `%name%`: defined e.g. in HTTP streams.
- All tags recognized by MPD: `%title%`, `%artist%`, `%album%`, `%date%`,
- `%comment%`, `%composer%`, `%performer%`, etc.
+ `%comment%`, `%composer%`, `%performer%` etc.
Functions
View
@@ -2,6 +2,7 @@
from PySide.QtCore import *
from PySide.QtGui import *
+from .dialogs import input_url
from .ui.browser import Ui_browser
@@ -75,13 +76,15 @@ def contextMenuEvent(self, e):
self.ui.remove.setVisible(self.current_view.can_remove())
self.ui.rename.setVisible(self.current_view.can_rename())
self.ui.copy.setVisible(self.current_view.can_copy())
+ self.ui.addurl.setVisible(self.current_view.model().can_add_url())
self.ui.details.setVisible(self.current_view.details() is not None)
self.ui.context_menu.popup(e.globalPos())
def on_state_changed(self, state):
c = state != 'disconnect'
for act in ('search', 'add', 'addplay', 'replace', 'replaceplay',
- 'addhighprio', 'remove', 'rename', 'copy', 'details', 'updatedb'):
+ 'addhighprio', 'remove', 'rename', 'copy', 'addurl', 'details',
+ 'updatedb'):
getattr(self.ui, act).setEnabled(c)
self.ui.dbpath.setEnabled(c)
self.ui.plpath.setEnabled(c)
@@ -126,6 +129,13 @@ def on_copy_triggered(self):
self.current_view.copy_selected()
@Slot()
+ def on_addurl_triggered(self):
+ if self.current_view.model().can_add_url():
+ url = input_url(self)
+ if url:
+ self.current_view.model().add_url(url)
+
+ @Slot()
def on_details_triggered(self):
d = self.current_view.details()
if d is not None:
View
@@ -38,6 +38,15 @@ def exec_(self, name, info, title):
super().exec_()
+def input_url(parent):
+ url, ok = QInputDialog.getText(parent,
+ QApplication.translate('input_url', 'Add URL'),
+ QApplication.translate('input_url', 'URL:'))
+ if ok and url:
+ return url
+ return None
+
+
class QygmyConfigParser(configparser.ConfigParser):
def __init__(self, **kwargs):
@@ -126,11 +135,13 @@ def retranslate(self):
'Disconnected)'
),
'current_song': self.tr(
+ '$if(%name%,[%name%] )'
'<span style="font-size: large; font-weight: bold">'
'$if2(%title%,%filename%)</span><br>'
'%artist%$if(%album%, \u2014 %album%)'
),
'playlist_item': self.tr(
+ '$if(%name%,[%name%] )'
'$if(%artist%,%artist% \u2014 )'
'$if2(%title%,%filename%)'
),
View
@@ -50,6 +50,7 @@ def retranslate(self):
),
'details': (
(self.tr('%file%'), None),
+ (self.tr('Name:'), self.tr('%name%')),
(self.tr('Title:'), self.tr('%title%')),
(self.tr('Artist:'), self.tr('%artist%')),
(self.tr('Album:'), self.tr('%album%')),
@@ -64,7 +65,7 @@ def retranslate(self):
)
}
- standard_tags = {'file', 'directory', 'playlist', 'filename', 'title',
+ standard_tags = {'file', 'directory', 'playlist', 'filename', 'name', 'title',
'artist', 'album', 'date', 'track', 'totaltracks', 'disc', 'totaldiscs',
'comment', 'length', 'lastmodified', 'composer', 'performer',
}
@@ -80,7 +81,7 @@ def _prepare_song(self, song, html=True):
song['prio'] = '0'
for key in ['file', 'directory', 'playlist']:
if key in song:
- filename = song[key].rsplit('/', 1)[-1]
+ filename = song[key].rstrip('/').rsplit('/', 1)[-1]
if filename:
song['filename'] = filename
if 'time' in song:
View
@@ -68,6 +68,9 @@ def can_set_priority(self, positions, prio):
def can_copy(self, positions):
return False
+ def can_add_url(self):
+ return False
+
@abstractmethod
def item_chosen(self, pos):
"""i.e. double-clicked or Return pressed."""
@@ -177,6 +180,12 @@ def can_add_directly(self, item, pos, **kwargs):
def add_one(self, item, pos, last, **kwargs):
pass
+ def can_add_url(self):
+ return True
+
+ def add_url(self, url):
+ self.add([{'file': url}])
+
def can_remove(self, positions):
return len(positions) > 0
View
@@ -5,7 +5,7 @@
from .formatter import Formatter
from .server import Server
from .browser import Browser
-from .dialogs import Info, Settings
+from .dialogs import Info, Settings, input_url
from .ui.main import Ui_main
from .__version__ import version
@@ -214,9 +214,9 @@ def on_state_changed(self, state):
self.ui.play.setVisible(state != 'play')
self.ui.pause.setVisible(state == 'play')
for e in ('previous', 'play', 'pause', 'stop', 'next', 'volume',
- 'add', 'clear', 'repeat', 'shuffle', 'single', 'consume',
- 'updatedb', 'save', 'randomize', 'details', 'statistics',
- 'louder', 'quieter', 'reverse',
+ 'add', 'addurl', 'clear', 'repeat', 'shuffle', 'single',
+ 'consume', 'updatedb', 'save', 'randomize', 'details',
+ 'statistics', 'louder', 'quieter', 'reverse',
'playback_menu', 'volume_menu', 'playlist_menu', 'outputs_menu'):
getattr(self.ui, e).setEnabled(c)
self.on_queue_selection_changed()
@@ -254,6 +254,12 @@ def on_statistics_triggered(self):
self.info.exec_('statistics', self.srv.statistics(), 'MPD statistics')
@Slot()
+ def on_addurl_triggered(self):
+ url = input_url(self)
+ if url:
+ self.srv.queue.add_url(url)
+
+ @Slot()
def on_save_triggered(self):
name = None
while True:
Oops, something went wrong.

0 comments on commit 8c60b4e

Please sign in to comment.