Skip to content

Commit

Permalink
Update version number and migrate to new HTTP API
Browse files Browse the repository at this point in the history
  • Loading branch information
Cip committed Jun 17, 2024
1 parent d012ca1 commit 39340ba
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 7 deletions.
34 changes: 34 additions & 0 deletions AcestreamHttpApi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import urllib.request
import json

class AcestreamHttpApi():
def __init__( self , *args, **kwargs):
self.aceHost = kwargs.get('aceHost')
self.acePort = kwargs.get('acePort')
url=kwargs.get('url')
self.contentId = url.replace('acestream://', '').replace('/', '')

def getPlayInfo(self):
response = urllib.request.urlopen("http://" + self.aceHost + ":" + str(self.acePort) +
"/ace/manifest.m3u8?format=json&content_id=" + self.contentId)
json_data = self.readJson(response)

# self.infohash = json_data['response']['infohash']
self.command_url = json_data['response']['command_url']
self.playback_url = json_data['response']['playback_url']
# self.playback_session_id = json_data['response']['playback_session_id']

return json_data

def stop(self):
response = urllib.request.urlopen(self.command_url + "?method=stop")
return self.readJson(response)

def readJson(self, response):
data = response.read()
str_data = data.decode()
return json.loads(str_data)




2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.acestreamsearch"
name="AcestreamSearch"
version="0.1.1"
version="0.2.0"
provider-name="Moromete">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v 0.2.0
1. migrate from deprecated api on port 62062 to new HTTP API on 6878

v 0.1.1
1. fix xbmc.translatePath error

Expand Down
11 changes: 9 additions & 2 deletions default.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from resources.acestreamsearch.channels import Channels
from resources.acestreamsearch.channel import Channel

from AcestreamHttpApi import AcestreamHttpApi

addon_id = 'plugin.video.acestreamsearch'
settings = xbmcaddon.Addon(id=addon_id)

Expand Down Expand Up @@ -112,8 +114,13 @@ def STREAM(name, url, ch_id):
xbmc.executebuiltin("Notification(%s,%s,%i)" % (addon.getLocalizedString(30303), "", 10000))
elif(SETTINGS.ACE_ENGINE_TYPE == 0): #use external
#play with acestream engine started on another machine or on the localhost
ace = acestream(player=player, url=url, listitem=listitem)
ace.engine_connect()
# ace = acestream(player=player, url=url, listitem=listitem)
# ace.engine_connect()

ace = AcestreamHttpApi(url=url, aceHost=SETTINGS.ACE_HOST, acePort=SETTINGS.ACE_PORT)
ace.getPlayInfo()
player.callback = ace.stop
player.play(ace.playback_url, listitem)

#######################################################################################################################
#######################################################################################################################
Expand Down
7 changes: 4 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ services:
acestream:
image: vstavrinov/acestream-engine
container_name: acestream-engine
ports:
- "6878:6878"
- "62062:62062"
network_mode: "host"
# ports:
# - "6878:6878"
# - "62062:62062"
restart: unless-stopped
2 changes: 1 addition & 1 deletion resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<setting type="lsep" label="30023"/>
<setting id="ace_engine_type" type="select" label="30029" lvalues="30028|30027" default="0"/>
<setting id="ace_host" type="text" label="30024" default="127.0.0.1"/>
<setting id="ace_port" type="number" label="30025" default="62062"/>
<setting id="ace_port" type="number" label="30025" default="6878"/>
</category>
</settings>
23 changes: 23 additions & 0 deletions tests/AcestreamHttpApi_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from AcestreamHttpApi import AcestreamHttpApi
import unittest

class AcestreamHttpApiTest(unittest.TestCase):
def testGetPlayInfo(self):
acestreamHttpApi = AcestreamHttpApi(url='acestream://bba1905fcd1c4975aec544047bf8e4cd23ce3fe0', aceHost='127.0.0.1', acePort='6878')
info = acestreamHttpApi.getPlayInfo()
print(info)
self.assertIsNotNone(info['response']['infohash'])
self.assertIsNotNone(info['response']['command_url'])
self.assertIsNotNone(info['response']['playback_url'])
self.assertIsNotNone(info['response']['playback_session_id'])

def testStop(self):
acestreamHttpApi = AcestreamHttpApi(url='acestream://bba1905fcd1c4975aec544047bf8e4cd23ce3fe0', aceHost='127.0.0.1', acePort='6878')
acestreamHttpApi.getPlayInfo()
response = acestreamHttpApi.stop()
self.assertEquals(response['response'], 'ok')
print(response)


if __name__ == '__main__':
unittest.main()

0 comments on commit 39340ba

Please sign in to comment.