Skip to content

Commit

Permalink
feat: Add scanning for local Chromecasts
Browse files Browse the repository at this point in the history
  • Loading branch information
skorokithakis committed Mar 16, 2017
1 parent 576a492 commit e9e3fb9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion catt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import click

from .controllers import Cache, CastController, get_chromecast, get_stream_info
from .controllers import Cache, CastController, get_chromecasts, get_chromecast, get_stream_info
from .http_server import serve_file


Expand Down Expand Up @@ -194,6 +194,14 @@ def info(settings):
cast.info()


@cli.command(short_help="Scan the local network and show all Chromecasts and their IPs.")
@click.pass_obj
def scan(settings):
click.echo("Scanning Chromecasts...")
for device in get_chromecasts():
click.echo("{0.host} - {0.device.friendly_name} - {0.device.manufacturer} {0.device.model_name}".format(device))


def writeconfig(settings):
try:
os.mkdir(CONFIG_DIR)
Expand Down
6 changes: 6 additions & 0 deletions catt/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ def get_stream_info(video_url):
return stream_info


def get_chromecasts():
devices = pychromecast.get_chromecasts()
devices.sort(key=lambda cc: cc.name)
return devices


def get_chromecast(device_name):
devices = pychromecast.get_chromecasts()
if not devices:
Expand Down

0 comments on commit e9e3fb9

Please sign in to comment.