- Added position
argument to music.mpd.add
- Added RSS feed parser plugin
This commit is contained in:
parent
02f4b1910f
commit
544979e7ff
2 changed files with 32 additions and 3 deletions
23
platypush/plugins/http/request/rss.py
Normal file
23
platypush/plugins/http/request/rss.py
Normal 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:
|
||||||
|
|
|
@ -207,7 +207,7 @@ class MusicMpdPlugin(MusicPlugin):
|
||||||
return self._exec('shuffle')
|
return self._exec('shuffle')
|
||||||
|
|
||||||
@action
|
@action
|
||||||
def add(self, resource):
|
def add(self, resource, position=None):
|
||||||
"""
|
"""
|
||||||
Add a resource (track, album, artist, folder etc.) to the current playlist
|
Add a resource (track, album, artist, folder etc.) to the current playlist
|
||||||
|
|
||||||
|
@ -219,14 +219,20 @@ class MusicMpdPlugin(MusicPlugin):
|
||||||
for r in resource:
|
for r in resource:
|
||||||
r = self._parse_resource(r)
|
r = self._parse_resource(r)
|
||||||
try:
|
try:
|
||||||
self._exec('add', r)
|
if position is None:
|
||||||
|
self._exec('add', r)
|
||||||
|
else:
|
||||||
|
self._exec('addid', r, position)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.warning('Could not add {}: {}'.format(r, e))
|
self.logger.warning('Could not add {}: {}'.format(r, e))
|
||||||
|
|
||||||
return self.status().output
|
return self.status().output
|
||||||
|
|
||||||
r = self._parse_resource(resource)
|
r = self._parse_resource(resource)
|
||||||
return self._exec('add', r)
|
|
||||||
|
if position is None:
|
||||||
|
return self._exec('add', r)
|
||||||
|
return self._exec('addid', r, position)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _parse_resource(cls, resource):
|
def _parse_resource(cls, resource):
|
||||||
|
|
Loading…
Reference in a new issue