Skip to content

Commit

Permalink
Fix streamripper plugin (exaile#868)
Browse files Browse the repository at this point in the history
* use custom useragent
* handle new version of playback_track_start

Thanks to @eri-trabiccolo
  • Loading branch information
luzip665 committed Mar 25, 2023
1 parent a2f6c8f commit 5b07675
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions plugins/streamripper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import shutil
from gi.repository import Gtk

from xl import event, player, settings
from xl import event, player, settings, common
from xl.nls import gettext as _
from xlgui.widgets import dialogs

Expand All @@ -36,8 +36,10 @@ def get_preferences_pane():


class Streamripper:
def __init__(self):
def __init__(self, exaile):
self.exaile = exaile
self.savedir = None
self.current_url = None

def toggle_record(self, add_call):
current_track = player.PLAYER.current
Expand All @@ -47,14 +49,18 @@ def toggle_record(self, add_call):
logger.warning('Streamripper can only record streams')
return True

self.current_url = current_track.get_loc_for_io()

self.savedir = settings.get_option(
'plugin/streamripper/save_location', os.getenv('HOME')
)
options = []
options.append('streamripper')
options.append(player.PLAYER._pipe.get_property('uri'))
options.append(common.sanitize_url(current_track.get_loc_for_io()))
options.append('-D')
options.append('%A/%a/%T')
options.append('-u')
options.append('"' + self.exaile.get_user_agent_string() + '"')
if settings.get_option('plugin/streamripper/single_file', False):
options.append("-a")
options.append("-A")
Expand Down Expand Up @@ -104,6 +110,9 @@ def stop_playback(self, type, player, track):
self.remove_callbacks()

def start_track(self, type, player, track):
current_url = track.get_loc_for_io()
if current_url == self.current_url:
return
self.stop_ripping()
if self.toggle_record(False):
self.button.set_active(False)
Expand All @@ -117,7 +126,7 @@ def remove_callbacks(self):

class Button(Streamripper):
def __init__(self, exaile):
self.exaile = exaile
Streamripper.__init__(self, exaile)
self.button = Gtk.ToggleButton()
self.button.set_relief(Gtk.ReliefStyle.NONE)
image = Gtk.Image.new_from_icon_name('media-record', Gtk.IconSize.MENU)
Expand Down

0 comments on commit 5b07675

Please sign in to comment.