-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update version number and migrate to new HTTP API
- Loading branch information
Cip
committed
Jun 17, 2024
1 parent
d012ca1
commit 39340ba
Showing
7 changed files
with
75 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |