Ticket #241 (new defect)

Opened 9 months ago

Last modified 7 days ago

Variable Replacement for OnPlayFiles is naieve...

Reported by: darrel.opry@… Owned by: quinox
Priority: minor Milestone: Release 1.3.0
Component: nicotine Version: 1.2.8
Keywords: Cc:

Description

I use Ubuntu Gutsy for my Desktop which comes with Rhythmbox by default. The command to tell rhythmbox to play a file from the command line is rhythmbox-client --play-uri=/path/to/song.mp3 The way the variable replacement works in OnPlayFiles? is to split the command on spaces, then searches the list for $ and replaces that element with the file path. However --play-uri=$ is not == $.

I updated gtkgui/userbrowser.py to:

def OnPlayFiles(self, widget, prefix = ""):
    path = self.selected_folder.replace("\\", os.sep)
    executable = self.frame.np.config.sections["players"]["default"]
    if "$" not in executable:
      return
    for fn in self.selected_files:
      file = os.sep.join([path, fn])
      if os.path.exists(file):
        command = [arg.replace('$', file) for arg in executable.split(" ")]
        os.spawnlp(os.P_NOWAIT, command[0], *command)

and gtkgui/downloads.py to :

  def OnPlayFiles(self, widget, prefix = ""):
    executable = self.frame.np.config.sections["players"]["default"]
    downloaddir = self.frame.np.config.sections["transfers"]["downloaddir"]
    if "$" not in executable:
      return
    for fn in self.selected_transfers:
      if fn.file is None:
        continue
      if os.path.exists(fn.file.name):
        path = fn.file.name
      else:
        basename = string.split(fn.filename, '\\')[-1]
        path = os.sep.join([downloaddir, basename])
      command = [arg.replace('$', path) for arg in executable.split(" ")]
      os.spawnlp(os.P_NOWAIT, command[0], *command)

And it works smashingly well... Sorry I forgot to save the originals to create a diff...

Attachments

Change History

Changed 7 days ago by offhand

  • owner changed from daelstorm to quinox

Changed 7 days ago by offhand

  • priority changed from major to minor

Add/Change #241 (Variable Replacement for OnPlayFiles is naieve...)

Author



Action
as new
 
Note: See TracTickets for help on using tickets.