diff --git a/LICENSE b/LICENSE index 1e4f560..f288702 100644 --- a/LICENSE +++ b/LICENSE @@ -631,9 +631,8 @@ to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - Raspberry Pi Media center - - Copyright (C) 2020 Paul Malcher + + Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/README.md b/README.md index 0d429a1..d755a02 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,2 @@ # rpimc Raspberry PI Medial Center - -Designed to be used with a google chromecasts. Componets seperated into branches. - -# Current Status as of 1/10/22 - -Allot of recent work on the Frontend. A large part due to having to update the code to a newer version of expo. Backend is ok for the most part a few items to do. See issues for a break down. - -# Frontend Branch -A react native android application, acts as a remote control. This is built using -Expo. - -# Backend Branch -A Python based web service and controller chromecasts - -# Notes -Example for cloning the frontend -git clone -b frontend https://github.com/kake26/rpimc.git - -Some values still hardcoded as its a work in progress. 1.0 Release will be soon. diff --git a/csrv.py b/csrv.py new file mode 100644 index 0000000..aa37fcf --- /dev/null +++ b/csrv.py @@ -0,0 +1,69 @@ +# Required Klein and Pychromecast modules +from twisted.web.static import File +from klein import run, route +from klein import Klein +import pychromecast +import time +import os +import json + + +app = Klein() + +chromecasts = pychromecast.get_chromecasts() +[cc.device.friendly_name for cc in chromecasts] +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() +print(cast.status) # Has display name and status text +mc = cast.media_controller + +@route('/movies/', branch=True) +def static(request): + return File("./movies") + +@route('/devices/') +def dlist(request): + + return mc + +@route('/play/') +def crun(request,fn): + mc.play_media('http://192.168.1.158:8080/movies/' + fn, 'video/mp4') # Update this IP to match yours + mc.block_until_active() + mc.pause() + time.sleep(2) + mc.play() + return 'Play' + +@route('/pause/') +def cpause(request): + mc.pause() + return 'Pause' + +@route('/resume/') +def cres(request): + mc.play() + return 'Resuming' + +@route('/stop/') +def cstop(request): + mc.stop() + return 'STOP!!!' + +@route('/list/') +def clist(request): + path = './movies' + files = os.listdir\ + (path) + e = [] + d = {'data' : e } + for x in range(len(files)): + #e.append("movie") + e.append(files[x]) + return json.dumps(d) + +@route('/') +def home(request): + return 'Welcome to the RPI Python based Chromecast Media Service! Please use the HTTP API!' + +run("192.168.1.158", 8080) # Obviously you need to change that IP to your local one