Compare commits

..

2 commits

Author SHA1 Message Date
Paul M
984b62d5b0
Update csrv.py
Added a few comments on whats required to run this script
2020-11-02 12:24:59 -06:00
Paul M
a71876c717
Add files via upload
initial backend upload
2020-11-02 12:20:06 -06:00
3 changed files with 71 additions and 22 deletions

View file

@ -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 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. the "copyright" line and a pointer to where the full notice is found.
Raspberry Pi Media center <one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
Copyright (C) 2020 Paul Malcher
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by

View file

@ -1,21 +1,2 @@
# rpimc # rpimc
Raspberry PI Medial Center 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.

69
csrv.py Normal file
View file

@ -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/<fn>')
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