Skip to content

Commit

Permalink
deadbeef_np.py 1.0: make script compatible with Python 3, drop Python…
Browse files Browse the repository at this point in the history
… 2 support
  • Loading branch information
flashcode committed Aug 18, 2024
1 parent c92a480 commit 81d35ff
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions python/deadbeef_np.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import commands
import subprocess
import weechat


def weechat_np(data, buffer, args):
read_track = commands.getoutput('deadbeef --nowplaying "%a - (%b) - %t [%@:BPS@bit / %@:BITRATE@kbps / %@:SAMPLERATE@Hz]"').split('\n')
weechat.command(buffer, '/me is currently listening to: ' + read_track[1])
read_track = subprocess.getoutput('deadbeef --nowplaying "%a - (%b) - %t [%@:BPS@bit / %@:BITRATE@kbps / %@:SAMPLERATE@Hz]"').split('\n')
if len(read_track) > 1:
weechat.command(buffer, '/me is currently listening to: ' + read_track[1])
else:
weechat.prnt(buffer, 'deadbeef_np: error: %s' % read_track[0])
return weechat.WEECHAT_RC_OK

weechat.register("deadbeef_np", "mwgg", "0.9", "MIT", "Show name of the song currently played by DeaDBeeF", "", "")

weechat.register("deadbeef_np", "mwgg", "1.0", "MIT", "Show name of the song currently played by DeaDBeeF", "", "")
weechat.hook_command("np", "Get/send now playing info.", "", "", "", "weechat_np", "")

0 comments on commit 81d35ff

Please sign in to comment.