Macast is a cross-platform application which using mpv as DLNA Media Renderer.

View on GitHub

Macast Development

On windows and Linux, we use pystray to add menubar icon support, and use pyinstaller to package application. We use rumps and py2app on MacOS which have better performance and smaller package size.

Development under MacOS

1. download mpv

mkdir -p bin && tar --strip-components 2 -C bin -xzvf mpv-latest.tar.gz

2. debug

pip install -r requirements/darwin.txt

3. package

pip install py2app
pip install setuptools==44.0.0 # try this if you cannot run
python py2app
cp -R bin dist/
open dist

Development under Windows

1. download mpv

$client = new-object System.Net.WebClient
7z x -obin mpv.7z *.exe

2. debug

pip install -r requirements/common.txt

3. package

pip install pyinstaller
pyinstaller --noconfirm -F -w --additional-hooks-dir=. --add-data=".version;." --add-data="macast/xml/*;macast/xml"  --add-data="i18n/zh_CN/LC_MESSAGES/*.mo;i18n/zh_CN/LC_MESSAGES" --add-data="assets/*;assets" --add-binary="bin/mpv.exe;bin" --icon=assets/icon.ico

Development under Linux (example: Ubuntu)

1. install mpv

sudo apt install mpv

2. debug

pip install -r requirements/common.txt
# if there is something wrong, try this:
export PYSTRAY_BACKEND=gtk && python3

Tips: Make sure you can use gi:

$ python3
Python 3.7.10 (default, Jun  3 2021, 17:51:26)
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi

if there is something wrong, try: sudo apt-get install python3-gi

if you use conda, check this

For details of GUI support, please refer to:

3. package

# build binary
pip install pyinstaller
pyinstaller --noconfirm -F -w --additional-hooks-dir=. --add-data=".version:." --add-data="macast/xml/*:macast/xml"  --add-data="i18n/zh_CN/LC_MESSAGES/*.mo:i18n/zh_CN/LC_MESSAGES" --add-data="assets/*:assets"
# build deb
export VERSION=`cat .version`
mkdir -p dist/DEBIAN
mkdir -p dist/usr/bin
mkdir -p dist/usr/share/applications
mkdir -p dist/usr/share/icons
echo -e "Package: Macast\nVersion: ${VERSION}\nArchitecture: amd64\nMaintainer: xfangfang\nDescription: DLNA Media Renderer\nDepends: mpv" > dist/DEBIAN/control
echo -e "[Desktop Entry]\nName=Macast\nComment=DLNA Media Renderer\nExec=/usr/bin/macast\nIcon=/usr/share/icons/Macast.png\nTerminal=false\nType=Application\nCategories=Video" > dist/usr/share/applications/macast.desktop
mv dist/Macast dist/usr/bin/macast
cp assets/icon.png dist/usr/share/icons/Macast.png
dpkg -b dist Macast-v${VERSION}.deb

4. build with docker (Thanks to cdrx/docker-pyinstaller)

Not sure whether it can run normally, used to add support for older versions of Linux.

cp requirements/common.txt requirements.txt
docker run \
  --env PYPI_INDEX_URL="" \
  --env PYPI_URL="" \
  --rm -v "$(pwd):/src/" xfangfang/pyinstaller-linux:python3 \
    'pip install --upgrade pip &&\
    pip install --no-use-pep517 --upgrade pyinstaller &&\
    pyinstaller --noconfirm -F -w \
      --additional-hooks-dir=. \
      --add-data=".version:." \
      --add-data="macast/xml/*:macast/xml" \
      --add-data="i18n/zh_CN/LC_MESSAGES/*.mo:i18n/zh_CN/LC_MESSAGES" \
      --add-data="assets/*:assets" \'