[casdrop.py]: Casting media files in python to Chromecast from a desktop folder
b0bby_seal
Posted on October 21, 2021
What does it do?
So, I made a python script that connects to a Chromecast and plays video & audio (.mp4 || .mp3) as soon as you drop your file in the chromecast
folder...
The idea came when I was looking for a quick way to share files onto my TV or Google Home Max without having to need a dedicated app. So, I hacked the b*tch!
On a serious note...
Here's what you need, before we get started:
A. Know the "friendly" name of your TV (CASDROP_TV_NAME)
and Speaker (CASDROP_SPKR_NAME)
.
B. Make sure your machine is running python ~> 3.9.7
(not mandatory, but you need at least python 3).
C. Install all dependencies to run this program: pip install requirements.txt
Once that's done...
Step1. Open a new terminal on your unix/linux based computer
NOTE: I ran these commands in a BASH environment, so I suggest doing the same...
Step2. Open params.sh
and edit the <>
with your own values. I ran into a few mistakes because I was putting in the wrong IP address.
Step3. Run the following command in your terminal:
ONLY RUN THIS ONCE!
bash params.sh #you may need to run this command with elevated privileges
Step4. Run the app:
1. Start a simple HTTP server:
`python -m SimpleHTTPServer`
2. Run the casting service:
`python3 casdrop.py`
3. Drop a file in your watch `CASDROP_WATCH_FOLDER` folder. Which in this case should be the folder we are looking to drop our files.
**At this point, your uploaded files should start streaming on the device(s).**
A side note: I know this is very short and cut to the point. However, I did this on purpose...Most of what you need is already on the internet. With that said, feel free to ask question if you lost, in the comment section below.
Reference:
CASDROP_WATCH_FOLDER
=> A folder you drop files in, to cast to device(s)CASDROP_SERVER_URL
=> TheIP
address you get fromSimpleHTTPServer
a.k.a(http://<ip_address>)
CASDROP_SPKR_NAME
and CASDROP_TV_NAME=> Displayed name of devices with (Ussually shown in cast menu on YouTube or Spotify mobile app)
Here's my sample param.sh
file
Features / Suggestions / TODO:
Currently you can drop a .mp3
or .mp4
which will cast with zero problem. However, I plan on adding more features down
the road...
Let me know in the comments if you'd like me to make a video explaining this is more detail
Posted on October 21, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
October 21, 2021
October 20, 2021