Skip to content

Commit

Permalink
cmus.py 1.1: make script compatible with Python 3, drop Python 2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
flashcode committed Aug 18, 2024
1 parent 2f8c068 commit c92a480
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions python/cmus.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
# Made as a port of cmus_xchat-v2.0, also made by Isaac Ross. Due to the nature of weechat's plugin/scripting API,
# this was mostly made using find/replace in a text editor

import commands
import subprocess
import weechat
import os

weechat.register("cmus", "Isaac Ross", "1.02", "GPL2", "Adds ability to control cmus and post the currently playing song in a channel", "", "")
weechat.register("cmus", "Isaac Ross", "1.1", "GPL2", "Adds ability to control cmus and post the currently playing song in a channel", "", "")


def help():
Expand All @@ -41,7 +41,7 @@ def help():
weechat.prnt('', "Keep in mind that most problems will probably be related to cmus-remote, not this script")

def np():
cmus = commands.getoutput('cmus-remote -Q')
cmus = subprocess.getoutput('cmus-remote -Q')
lines = cmus.split('\n')

#some redundant loops later, but streamline as needed
Expand Down Expand Up @@ -89,14 +89,14 @@ def control(data, buffer, args):
os.system('cmus-remote -S')
weechat.prnt('', 'Toggled shuffle on/off.')
elif args[0].lower() == 'status':
status = commands.getoutput('cmus-remote -Q')
status = subprocess.getoutput('cmus-remote -Q')
status = status.split('\n')
for line in status:
weechat.prnt('', " -- " + line)
elif args[0].lower() == 'help':
help()
elif args[0].lower() == 'file':
filename = commands.getoutput('cmus-remote -Q')
filename = subprocess.getoutput('cmus-remote -Q')
filename = filename.split('\n')
newname = filename[1]
newname = newname.replace('file', '', 1)
Expand Down

0 comments on commit c92a480

Please sign in to comment.