From 9de7b7625df758f85a9d26e8d06bcb823016263c Mon Sep 17 00:00:00 2001 From: John Ellis Date: Mon, 20 Mar 2017 19:35:04 -0400 Subject: [PATCH] Fixed imports on lessons; filtered out explicit tracks on Google Music --- README.md | 2 +- debian/changelog | 5 ++--- home/pi/hack-clock/lessons/1/run_clock.py | 4 ++-- home/pi/hack-clock/lessons/2/run_clock.py | 4 ++-- home/pi/hack-clock/lessons/3/run_clock.py | 4 ++-- home/pi/hack-clock/lessons/4/run_clock.py | 6 +++--- home/pi/hack-clock/lessons/5/run_clock.py | 8 ++++---- home/pi/hack-clock/lessons/6/run_clock.py | 12 ++++++------ home/pi/hack-clock/lessons/final/run_clock.py | 12 ++++++------ home/pi/hack-clock/lessons/gpio/run_clock.py | 8 ++++---- home/pi/hack-clock/lessons/musiclover/run_clock.py | 12 ++++++------ lib/hackclock/runapp/Libs/GoogleMusic.py | 7 ++++++- package.sh | 2 +- setup.py | 2 +- 14 files changed, 46 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index e5c47ef..db07fd3 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ I'm assuming that you are starting with the Raspian Minimal Linux distribution. 1. Make sure your Raspberry Pi is up to date with the latest packages & firmware with `sudo apt-get update; sudo apt-get dist-upgrade` 2. Enable I2C by executing `sudo raspi-config` as described in Adafruit's tutorial: https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c 3. Add the necessary Python and GStreamer dependencies using the command: `sudo apt-get install wiringpi python-bottle python-requests python-oauth2client python-httplib2 python-setuptools python-pip python-dev python-dateutil python-smbus gstreamer0.10-x gstreamer-tools gstreamer0.10-plugins-base gstreamer0.10-plugins-good gstreamer0.10-plugins-bad gstreamer0.10-plugins-ugly python-gst0.10` -4. Install hack-clock via `wget https://github.com/deckerego/hack-clock/releases/download/2.1.7/python-hackclock_2.1.7-1_all.deb; sudo dpkg -i python-hackclock_2.1.7-1_all.deb` +4. Install hack-clock via `wget https://github.com/deckerego/hack-clock/releases/download/2.1.8/python-hackclock_2.1.8-1_all.deb; sudo dpkg -i python-hackclock_2.1.8-1_all.deb` 5. Tweak `/etc/hack-clock.conf` and `/etc/default/hack-clock` to fit your needs (GPIO pins, correct weather station, etc.). A list of observed weather stations is available at http://forecast.weather.gov/stations.php 6. Reboot your Pi to re-load modules and start the IDE web server diff --git a/debian/changelog b/debian/changelog index 7ded14a..8a9c45e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,5 @@ -hackclock (2.1.7-1) stable; urgency=low +hackclock (2.1.8-1) stable; urgency=low - * Detect if I2S is already _ignored_, then allow standard Pi audio to continue - * Changed icons for "save" and "restore" in IDE + * Filter out explicit songs from Google Music radio streams -- DeckerEgo Tue, 01 Mar 2017 21:32:00 -0500 diff --git a/home/pi/hack-clock/lessons/1/run_clock.py b/home/pi/hack-clock/lessons/1/run_clock.py index f8f4ff2..8ad4167 100755 --- a/home/pi/hack-clock/lessons/1/run_clock.py +++ b/home/pi/hack-clock/lessons/1/run_clock.py @@ -1,7 +1,7 @@ #!/usr/bin/python -from Libs.Clock import Clock -from Libs.SevenSegment import Display +from hackclock.runapp.Libs.Clock import Clock +from hackclock.runapp.Libs.SevenSegment import Display # Connect to the internal machine clock clock = Clock() diff --git a/home/pi/hack-clock/lessons/2/run_clock.py b/home/pi/hack-clock/lessons/2/run_clock.py index a2f9104..f87af85 100755 --- a/home/pi/hack-clock/lessons/2/run_clock.py +++ b/home/pi/hack-clock/lessons/2/run_clock.py @@ -1,8 +1,8 @@ #!/usr/bin/python from datetime import datetime -from Libs.Clock import Clock -from Libs.SevenSegment import Display +from hackclock.runapp.Libs.Clock import Clock +from hackclock.runapp.Libs.SevenSegment import Display # Connect to the internal machine clock clock = Clock() diff --git a/home/pi/hack-clock/lessons/3/run_clock.py b/home/pi/hack-clock/lessons/3/run_clock.py index 0e8f4bf..7509766 100755 --- a/home/pi/hack-clock/lessons/3/run_clock.py +++ b/home/pi/hack-clock/lessons/3/run_clock.py @@ -1,8 +1,8 @@ #!/usr/bin/python from datetime import datetime -from Libs.Clock import Clock -from Libs.SevenSegment import Display +from hackclock.runapp.Libs.Clock import Clock +from hackclock.runapp.Libs.SevenSegment import Display # Connect to the internal machine clock clock = Clock() diff --git a/home/pi/hack-clock/lessons/4/run_clock.py b/home/pi/hack-clock/lessons/4/run_clock.py index 950b4c4..397827b 100755 --- a/home/pi/hack-clock/lessons/4/run_clock.py +++ b/home/pi/hack-clock/lessons/4/run_clock.py @@ -1,9 +1,9 @@ #!/usr/bin/python from datetime import datetime -from Libs.Clock import Clock -from Libs.SevenSegment import Display -from Libs.GStreamer import Speaker +from hackclock.runapp.Libs.Clock import Clock +from hackclock.runapp.Libs.SevenSegment import Display +from hackclock.runapp.Libs.GStreamer import Speaker # Connect to the internal machine clock clock = Clock() diff --git a/home/pi/hack-clock/lessons/5/run_clock.py b/home/pi/hack-clock/lessons/5/run_clock.py index 5996d84..80e9f6e 100755 --- a/home/pi/hack-clock/lessons/5/run_clock.py +++ b/home/pi/hack-clock/lessons/5/run_clock.py @@ -1,10 +1,10 @@ #!/usr/bin/python from datetime import datetime -from Libs.Clock import Clock -from Libs.SevenSegment import Display -from Libs.Input import Button -from Libs.GStreamer import Speaker +from hackclock.runapp.Libs.Clock import Clock +from hackclock.runapp.Libs.SevenSegment import Display +from hackclock.runapp.Libs.Input import Button +from hackclock.runapp.Libs.GStreamer import Speaker # Connect to the internal machine clock clock = Clock() diff --git a/home/pi/hack-clock/lessons/6/run_clock.py b/home/pi/hack-clock/lessons/6/run_clock.py index 1535ac1..15550a3 100755 --- a/home/pi/hack-clock/lessons/6/run_clock.py +++ b/home/pi/hack-clock/lessons/6/run_clock.py @@ -1,12 +1,12 @@ #!/usr/bin/python from datetime import datetime -from Libs.Clock import Clock -from Libs.SevenSegment import Display -from Libs.Weather import Weather -from Libs.Input import Button -from Libs.GStreamer import Speaker -from config import configuration +from hackclock.runapp.Libs.Clock import Clock +from hackclock.runapp.Libs.SevenSegment import Display +from hackclock.runapp.Libs.Weather import Weather +from hackclock.runapp.Libs.Input import Button +from hackclock.runapp.Libs.GStreamer import Speaker +from hackclock.config import configuration # The weather station station_name = configuration.get('weather_station') diff --git a/home/pi/hack-clock/lessons/final/run_clock.py b/home/pi/hack-clock/lessons/final/run_clock.py index 1535ac1..15550a3 100755 --- a/home/pi/hack-clock/lessons/final/run_clock.py +++ b/home/pi/hack-clock/lessons/final/run_clock.py @@ -1,12 +1,12 @@ #!/usr/bin/python from datetime import datetime -from Libs.Clock import Clock -from Libs.SevenSegment import Display -from Libs.Weather import Weather -from Libs.Input import Button -from Libs.GStreamer import Speaker -from config import configuration +from hackclock.runapp.Libs.Clock import Clock +from hackclock.runapp.Libs.SevenSegment import Display +from hackclock.runapp.Libs.Weather import Weather +from hackclock.runapp.Libs.Input import Button +from hackclock.runapp.Libs.GStreamer import Speaker +from hackclock.config import configuration # The weather station station_name = configuration.get('weather_station') diff --git a/home/pi/hack-clock/lessons/gpio/run_clock.py b/home/pi/hack-clock/lessons/gpio/run_clock.py index 5361742..576f020 100644 --- a/home/pi/hack-clock/lessons/gpio/run_clock.py +++ b/home/pi/hack-clock/lessons/gpio/run_clock.py @@ -1,8 +1,8 @@ from datetime import datetime -from Libs.SevenSegment import Display -from Libs.Output import Switch -from Libs.Clock import Clock -from Libs.Input import Button +from hackclock.runapp.Libs.SevenSegment import Display +from hackclock.runapp.Libs.Output import Switch +from hackclock.runapp.Libs.Clock import Clock +from hackclock.runapp.Libs.Input import Button Is_Evening = None LED_On = None diff --git a/home/pi/hack-clock/lessons/musiclover/run_clock.py b/home/pi/hack-clock/lessons/musiclover/run_clock.py index aab3c8e..3cfa962 100644 --- a/home/pi/hack-clock/lessons/musiclover/run_clock.py +++ b/home/pi/hack-clock/lessons/musiclover/run_clock.py @@ -2,12 +2,12 @@ from datetime import datetime import random -from Libs.Clock import Clock -from Libs.SevenSegment import Display -from Libs.Weather import Weather -from Libs.Input import Button -from Libs.GStreamer import Speaker -from config import configuration +from hackclock.runapp.Libs.Clock import Clock +from hackclock.runapp.Libs.SevenSegment import Display +from hackclock.runapp.Libs.Weather import Weather +from hackclock.runapp.Libs.Input import Button +from hackclock.runapp.Libs.GStreamer import Speaker +from hackclock.config import configuration # Connect to the internal machine clock clock = Clock() diff --git a/lib/hackclock/runapp/Libs/GoogleMusic.py b/lib/hackclock/runapp/Libs/GoogleMusic.py index 76cc22c..ece2cd6 100644 --- a/lib/hackclock/runapp/Libs/GoogleMusic.py +++ b/lib/hackclock/runapp/Libs/GoogleMusic.py @@ -7,7 +7,7 @@ logger = logging.getLogger('google_music') console = logging.StreamHandler() -console.setLevel(logging.WARNING) +console.setLevel(logging.DEBUG) logger.addHandler(console) class AudioStream: @@ -34,6 +34,11 @@ def __fetchTrackIDs(self, station_id): tracklist = self.__client.get_station_tracks(station_id, num_tracks=self.__track_prefetch) logger.info("Received tracks: %r" % json.dumps(tracklist)) + # Filter out explicit tracks, where non-explicit is explicitType=2 + tracklist = [track for track in tracklist if not 'explicitType' in track or track['explicitType'] == "2"] + logger.info("Non-explicit tracks: %r" % json.dumps(tracklist)) + + # Fetch both song IDs and Nautilus (old) IDs songids = [track['id'] for track in tracklist if 'id' in track] nautids = [track['nid'] for track in tracklist if 'nid' in track] diff --git a/package.sh b/package.sh index bc08a56..db9878f 100755 --- a/package.sh +++ b/package.sh @@ -7,7 +7,7 @@ rm home/pi/hack-clock/backups/blocks_clock.* cd .. echo "Compressing file..." -tar Jcf hackclock_2.1.7.orig.tar.xz hack-clock/ +tar Jcf hackclock_2.1.8.orig.tar.xz hack-clock/ cd hack-clock dpkg-buildpackage -rfakeroot -uc -us diff --git a/setup.py b/setup.py index 3e6b3b8..7c87d9e 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ def all_files(newroot, oldroot): setup( name='HackClock', - version='2.1.7', + version='2.1.8', description='A hackable alarm clock for the Raspberry Pi', author='DeckerEgo', author_email='john@deckerego.net',