Python AceStream
Python interface to interact with the AceStream Engine, HTTP API and Search API.
Installation
pip install acestream
Usage
import time
import subprocess
from acestream.server import Server
from acestream.engine import Engine
from acestream.stream import Stream
engine = Engine('acestreamengine', client_console=True)
server = Server(host='streams.com', port=6880)
if not server.available:
server = Server(host='127.0.0.1', port=6878)
if not server.available:
engine.start()
while not engine.running:
time.sleep(1)
stream = Stream(server, id='ff36fce40a7d2042e327eaf9f215a1e9cb622b56')
stream.start()
player = subprocess.Popen(['mpv', stream.playback_url])
player.communicate()
stream.stop()
engine.stop()
Search
import time
import random
import subprocess
from acestream.server import Server
from acestream.engine import Engine
from acestream.search import Search
engine = Engine('acestreamengine', client_console=True)
server = Server(host='127.0.0.1', port=6878)
if not server.available:
engine.start(stdout=subprocess.PIPE, stderr=subprocess.PIPE)
while not engine.running:
time.sleep(1)
search = Search(server, category='sport')
search.get(page=1)
for result in search.results:
print("%40s %10s %40s" % (result.name, result.bitrate, result.infohash))
stream = random.choice(search.results).stream
stream.start(hls=True, transcode_audio=True)
player = subprocess.Popen(['mpv', stream.playback_url])
player.communicate()
stream.stop()
engine.stop()
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/jonian/python-acestream.
License
Python AceStream is available as open source under the terms of the GPLv3