mirror of
https://github.com/JohnDoee/deluge-streaming/
synced 2026-07-01 07:31:17 -07:00
Fixed up stream clicking stuff
This commit is contained in:
@@ -634,7 +634,7 @@ class Core(CorePluginBase):
|
|||||||
|
|
||||||
port = self.config['port']
|
port = self.config['port']
|
||||||
ip = self.config['ip']
|
ip = self.config['ip']
|
||||||
elif self.config['serve_method'] == 'webui': # this webserver is fubar
|
elif self.config['serve_method'] == 'webui' and self.check_webui(): # this webserver is fubar
|
||||||
plugin_manager = component.get("CorePluginManager")
|
plugin_manager = component.get("CorePluginManager")
|
||||||
|
|
||||||
webui_plugin = plugin_manager['WebUi'].plugin
|
webui_plugin = plugin_manager['WebUi'].plugin
|
||||||
@@ -658,6 +658,7 @@ class Core(CorePluginBase):
|
|||||||
self.site.stopFactory()
|
self.site.stopFactory()
|
||||||
self.torrent_handler.shutdown()
|
self.torrent_handler.shutdown()
|
||||||
|
|
||||||
|
if self.check_webui():
|
||||||
plugin_manager = component.get("CorePluginManager")
|
plugin_manager = component.get("CorePluginManager")
|
||||||
webui_plugin = plugin_manager['WebUi'].plugin
|
webui_plugin = plugin_manager['WebUi'].plugin
|
||||||
|
|
||||||
|
|||||||
@@ -579,7 +579,7 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkCheckButton" id="input_use_stream_urls">
|
<widget class="GtkCheckButton" id="input_use_stream_urls">
|
||||||
<property name="label" translatable="yes">Use stream urls</property>
|
<property name="label" translatable="yes">Use stream protocol urls</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">False</property>
|
<property name="receives_default">False</property>
|
||||||
@@ -594,7 +594,7 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkCheckButton" id="input_auto_open_stream_urls">
|
<widget class="GtkCheckButton" id="input_auto_open_stream_urls">
|
||||||
<property name="label" translatable="yes">Auto-open stream urls</property>
|
<property name="label" translatable="yes">Auto-open stream protocol urls</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">False</property>
|
<property name="receives_default">False</property>
|
||||||
|
|||||||
@@ -240,14 +240,14 @@ PreferencePage = Ext.extend(Ext.Panel, {
|
|||||||
om.bind('use_stream_urls', fieldset.add({
|
om.bind('use_stream_urls', fieldset.add({
|
||||||
xtype: 'checkbox',
|
xtype: 'checkbox',
|
||||||
name: 'use_stream_urls',
|
name: 'use_stream_urls',
|
||||||
boxLabel: 'Use stream urls',
|
boxLabel: 'Use stream protocol urls',
|
||||||
style: 'margin-left: 12px;'
|
style: 'margin-left: 12px;'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
om.bind('auto_open_stream_urls', fieldset.add({
|
om.bind('auto_open_stream_urls', fieldset.add({
|
||||||
xtype: 'checkbox',
|
xtype: 'checkbox',
|
||||||
name: 'auto_open_stream_urls',
|
name: 'auto_open_stream_urls',
|
||||||
boxLabel: 'Auto-open stream urls',
|
boxLabel: 'Auto-open stream protocol urls',
|
||||||
style: 'margin-left: 12px;'
|
style: 'margin-left: 12px;'
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -39,7 +39,9 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import gtk
|
import gtk
|
||||||
import webbrowser
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
from deluge.log import LOG as log
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
@@ -53,35 +55,18 @@ from twisted.web import server, resource
|
|||||||
|
|
||||||
from common import get_resource
|
from common import get_resource
|
||||||
|
|
||||||
class LocalAddResource(resource.Resource):
|
|
||||||
gtkui = None
|
|
||||||
isLeaf = True
|
|
||||||
|
|
||||||
def __init__(self, gtkui):
|
def execute_url(url):
|
||||||
self.gtkui = gtkui
|
if sys.platform == 'win32':
|
||||||
resource.Resource.__init__(self)
|
os.startfile(url)
|
||||||
|
elif sys.platform == 'darwin':
|
||||||
|
subprocess.Popen(['open', url])
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
subprocess.Popen(['xdg-open', url])
|
||||||
|
except OSError:
|
||||||
|
print 'Unable to open URL %s' % (url, )
|
||||||
|
|
||||||
def render_GET(self, request):
|
|
||||||
useragent = request.getHeader('User-Agent')
|
|
||||||
if 'Deluge-Streamer' not in useragent:
|
|
||||||
request.setResponseCode(401)
|
|
||||||
return 'Unauthorized'
|
|
||||||
|
|
||||||
torrent_url = request.args.get('url', None)
|
|
||||||
if not torrent_url:
|
|
||||||
return json.dumps({'status': 'error', 'message': 'missing url in request'})
|
|
||||||
|
|
||||||
torrent_file = request.args.get('file', None)
|
|
||||||
if torrent_file:
|
|
||||||
torrent_file = torrent_file[0]
|
|
||||||
|
|
||||||
infohash = request.args.get('infohash', None)
|
|
||||||
if infohash:
|
|
||||||
infohash = infohash[0]
|
|
||||||
|
|
||||||
client.streaming.stream_torrent(url=torrent_url[0], infohash=infohash, filepath_or_index=torrent_file).addCallback(self.gtkui.stream_ready)
|
|
||||||
|
|
||||||
return json.dumps({'status': 'ok', 'message': 'queued'})
|
|
||||||
|
|
||||||
class GtkUI(GtkPluginBase):
|
class GtkUI(GtkPluginBase):
|
||||||
def enable(self):
|
def enable(self):
|
||||||
@@ -115,11 +100,6 @@ class GtkUI(GtkPluginBase):
|
|||||||
self.sep_torrentmenu.show()
|
self.sep_torrentmenu.show()
|
||||||
self.item_torrentmenu.show()
|
self.item_torrentmenu.show()
|
||||||
|
|
||||||
self.resource = LocalAddResource(self)
|
|
||||||
self.site = server.Site(self.resource)
|
|
||||||
self.listening = reactor.listenTCP(40747, self.site, interface='127.0.0.1')
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
|
||||||
def disable(self):
|
def disable(self):
|
||||||
component.get("Preferences").remove_page("Streaming")
|
component.get("Preferences").remove_page("Streaming")
|
||||||
component.get("PluginManager").deregister_hook("on_apply_prefs", self.on_apply_prefs)
|
component.get("PluginManager").deregister_hook("on_apply_prefs", self.on_apply_prefs)
|
||||||
@@ -135,9 +115,6 @@ class GtkUI(GtkPluginBase):
|
|||||||
torrentmenu.remove(self.item_torrentmenu)
|
torrentmenu.remove(self.item_torrentmenu)
|
||||||
torrentmenu.remove(self.sep_torrentmenu)
|
torrentmenu.remove(self.sep_torrentmenu)
|
||||||
|
|
||||||
self.site.stopFactory()
|
|
||||||
yield self.listening.stopListening()
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def on_apply_prefs(self):
|
def on_apply_prefs(self):
|
||||||
log.debug("applying prefs for Streaming")
|
log.debug("applying prefs for Streaming")
|
||||||
@@ -210,9 +187,13 @@ class GtkUI(GtkPluginBase):
|
|||||||
if result.get('use_stream_urls', False):
|
if result.get('use_stream_urls', False):
|
||||||
url = "stream+%s" % result['url']
|
url = "stream+%s" % result['url']
|
||||||
if result.get('auto_open_stream_urls', False):
|
if result.get('auto_open_stream_urls', False):
|
||||||
threads.deferToThread(webbrowser.open, url)
|
threads.deferToThread(execute_url, url)
|
||||||
else:
|
else:
|
||||||
dialogs.InformationDialog('Stream ready', '<a href="%s">Click here to open it</a>' % url).run()
|
def on_dialog_callback(response):
|
||||||
|
if response == gtk.RESPONSE_YES:
|
||||||
|
threads.deferToThread(execute_url, url)
|
||||||
|
|
||||||
|
dialogs.YesNoDialog('Stream ready', 'Do you want to play the video?').run().addCallback(on_dialog_callback)
|
||||||
else:
|
else:
|
||||||
dialogs.ErrorDialog('Stream ready', 'Copy the link into a media player', details=result['url']).run()
|
dialogs.ErrorDialog('Stream ready', 'Copy the link into a media player', details=result['url']).run()
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user