- Added position argument to music.mpd.add

- Added RSS feed parser plugin
This commit is contained in:
Fabio Manganiello 2019-01-09 18:43:13 +01:00
parent 02f4b1910f
commit 544979e7ff
2 changed files with 32 additions and 3 deletions

View file

@ -0,0 +1,23 @@
import feedparser
from platypush.plugins import action
from platypush.plugins.http.request import HttpRequestPlugin
class HttpRequestRssPlugin(HttpRequestPlugin):
"""
Plugin to programmatically retrieve and parse an RSS feed URL.
Requires:
* **feedparser** (``pip install feedparser``)
"""
@action
def get(self, url):
response = super().get(url, output='text').output
feed = feedparser.parse(response)
return feed.entries
# vim:sw=4:ts=4:et:

View file

@ -207,7 +207,7 @@ class MusicMpdPlugin(MusicPlugin):
return self._exec('shuffle')
@action
def add(self, resource):
def add(self, resource, position=None):
"""
Add a resource (track, album, artist, folder etc.) to the current playlist
@ -219,14 +219,20 @@ class MusicMpdPlugin(MusicPlugin):
for r in resource:
r = self._parse_resource(r)
try:
if position is None:
self._exec('add', r)
else:
self._exec('addid', r, position)
except Exception as e:
self.logger.warning('Could not add {}: {}'.format(r, e))
return self.status().output
r = self._parse_resource(resource)
if position is None:
return self._exec('add', r)
return self._exec('addid', r, position)
@classmethod
def _parse_resource(cls, resource):