Update csrv.py
Added a few comments on whats required to run this script
This commit is contained in:
parent
a71876c717
commit
984b62d5b0
1 changed files with 4 additions and 3 deletions
7
csrv.py
7
csrv.py
|
@ -1,3 +1,4 @@
|
||||||
|
# Required Klein and Pychromecast modules
|
||||||
from twisted.web.static import File
|
from twisted.web.static import File
|
||||||
from klein import run, route
|
from klein import run, route
|
||||||
from klein import Klein
|
from klein import Klein
|
||||||
|
@ -11,7 +12,7 @@ app = Klein()
|
||||||
|
|
||||||
chromecasts = pychromecast.get_chromecasts()
|
chromecasts = pychromecast.get_chromecasts()
|
||||||
[cc.device.friendly_name for cc in chromecasts]
|
[cc.device.friendly_name for cc in chromecasts]
|
||||||
cast = next(cc for cc in chromecasts if cc.device.friendly_name == "living room")
|
cast = next(cc for cc in chromecasts if cc.device.friendly_name == "living room") # You may need to change to your chromecast name for now
|
||||||
cast.wait()
|
cast.wait()
|
||||||
print(cast.status) # Has display name and status text
|
print(cast.status) # Has display name and status text
|
||||||
mc = cast.media_controller
|
mc = cast.media_controller
|
||||||
|
@ -27,7 +28,7 @@ def dlist(request):
|
||||||
|
|
||||||
@route('/play/<fn>')
|
@route('/play/<fn>')
|
||||||
def crun(request,fn):
|
def crun(request,fn):
|
||||||
mc.play_media('http://192.168.1.158:8080/movies/' + fn, 'video/mp4')
|
mc.play_media('http://192.168.1.158:8080/movies/' + fn, 'video/mp4') # Update this IP to match yours
|
||||||
mc.block_until_active()
|
mc.block_until_active()
|
||||||
mc.pause()
|
mc.pause()
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
@ -65,4 +66,4 @@ def clist(request):
|
||||||
def home(request):
|
def home(request):
|
||||||
return 'Welcome to the RPI Python based Chromecast Media Service! Please use the HTTP API!'
|
return 'Welcome to the RPI Python based Chromecast Media Service! Please use the HTTP API!'
|
||||||
|
|
||||||
run("192.168.1.158", 8080)
|
run("192.168.1.158", 8080) # Obviously you need to change that IP to your local one
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue