From 72e57a8bc5bdc944c0dd550051bad2cb44f9569d Mon Sep 17 00:00:00 2001 From: Erik Price Date: Sun, 25 Feb 2018 19:52:55 -0800 Subject: [PATCH 1/5] Drop support for Python 2 --- README.rst | 8 ++++++-- lastcast/__init__.py | 15 ++++++++------- setup.py | 20 +++++++++++++++++--- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index b76dd36..e17d288 100644 --- a/README.rst +++ b/README.rst @@ -7,6 +7,10 @@ By default, lastcast will scrobble music playing on Spotify, Google Play Music, SoundCloud, and Plex, but can be configured to scrobble any media player that supports Chromecast. +**Python 2 is no longer supported as of lastcast 1.0.0.** + +If you need Python 2, please install ``lastcast < 1.0.0``. + Getting started --------------- @@ -45,8 +49,8 @@ Now everything should be set up. When you want to start scrobbling, simply run ``lastcast`` in the terminal. Generally, I run lastcast like so: ``while true; do lastcast; sleep 5; done``. -This will help in case lastcast crashes for whatever reason (please open an issue -if you see something go wrong!) +This will help in case lastcast crashes for whatever reason (please +open an issue if you see something go wrong!) Linux / systemd instructions ---------------------------- diff --git a/lastcast/__init__.py b/lastcast/__init__.py index 98fde73..b06de9b 100644 --- a/lastcast/__init__.py +++ b/lastcast/__init__.py @@ -16,7 +16,7 @@ logging.basicConfig() # Default set of apps to scrobble from. -APP_WHITELIST = [u'Spotify', u'Google Play Music', u'SoundCloud', u'Plex'] +APP_WHITELIST = ['Spotify', 'Google Play Music', 'SoundCloud', 'Plex'] SCROBBLE_THRESHOLD_PCT = 0.50 SCROBBLE_THRESHOLD_SECS = 120 @@ -144,7 +144,7 @@ def _connect_chromecast(self, available_devices=None): self.cast = None if not available_devices: - available_devices = pychromecast.get_chromecasts(tries=1, retry_wait=0.01) + available_devices = pychromecast.get_chromecasts(tries=1) matching_devices = [ c for c in available_devices @@ -181,9 +181,10 @@ def _on_media_controller_status(self, status): # whichever comes first). # # Don't scrobble the same thing over and over - if meta != self.last_scrobbled and \ - (self.current_time > SCROBBLE_THRESHOLD_SECS or \ - (self.current_time / status.duration) >= SCROBBLE_THRESHOLD_PCT): + hit_threshold = self.current_time > SCROBBLE_THRESHOLD_SECS or \ + (self.current_time / status.duration) >= SCROBBLE_THRESHOLD_PCT + + if meta != self.last_scrobbled and hit_threshold: self._log_scrobble(meta) def _log_now_playing(self, track_meta): @@ -205,7 +206,7 @@ def _log_now_playing(self, track_meta): def _log_scrobble(self, track_meta): ''' Scrobble current track to user's profile. ''' - click.echo(u'Scrobbling: {artist} - {title} [{album}]'.format(**track_meta)) + click.echo('Scrobbling: {artist} - {title} [{album}]'.format(**track_meta)) for scrobbler in self.scrobblers: try: @@ -386,7 +387,7 @@ def main(config, wizard): # If we have any devices missing, periodically try to connect to them if retry_missing and missing and i % RECONNECT_INTERVAL == 0: click.echo('Retrying missing devices: %s' % ', '.join(missing)) - available = pychromecast.get_chromecasts(tries=1, retry_wait=0.01) + available = pychromecast.get_chromecasts(tries=1) new_devices, missing = connect_to_devices(config, missing, available) listeners.extend(new_devices) diff --git a/setup.py b/setup.py index d614e3a..5fd589d 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,15 @@ +import sys from setuptools import setup +# Be verbose about Python < 3.4 being deprecated. +if sys.version_info < (3, 4): + print('\n' * 3 + '*' * 64) + print('lastcast requires Python 3.4+, and might be broken if run with\n' + 'this version of Python.') + print('*' * 64 + '\n' * 3) + + setup( name='lastcast', version='0.7.0', @@ -14,10 +23,15 @@ ], }, license='MIT', + classifiers=[ + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Operating System :: OS Independent", + ], install_requires=[ - 'PyChromecast==1.0.3', - 'click==6.2', + 'PyChromecast==2.0.0', + 'click==6.7', 'pylast==1.7.0', - 'toml==0.9.1', + 'toml==0.9.4', ] ) From 56535cc07d57cd324f70cd5867e6b5925c77fc28 Mon Sep 17 00:00:00 2001 From: Erik Price Date: Sun, 25 Feb 2018 21:12:57 -0800 Subject: [PATCH 2/5] Explicitly reference version --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index e17d288..3788cd9 100644 --- a/README.rst +++ b/README.rst @@ -9,7 +9,7 @@ scrobble any media player that supports Chromecast. **Python 2 is no longer supported as of lastcast 1.0.0.** -If you need Python 2, please install ``lastcast < 1.0.0``. +If you need Python 2, please install ``lastcast==0.7.0``. Getting started --------------- From e00e6d2a65689f091af08dd1115a1a7e5754a011 Mon Sep 17 00:00:00 2001 From: Erik Price Date: Sun, 25 Feb 2018 21:16:07 -0800 Subject: [PATCH 3/5] version 1.0.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5fd589d..29f6dc4 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name='lastcast', - version='0.7.0', + version='1.0.0', description='Scrobble music to last.fm from Chromecast.', author='Erik Price', url='https://github.com/erik/lastcast', From ce726c61b886f23a0f430a5432a330db4b07aaaa Mon Sep 17 00:00:00 2001 From: Erik Price Date: Tue, 27 Feb 2018 22:41:37 -0800 Subject: [PATCH 4/5] use pip3 instead of pip in README --- README.rst | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index 3788cd9..7546523 100644 --- a/README.rst +++ b/README.rst @@ -14,7 +14,7 @@ If you need Python 2, please install ``lastcast==0.7.0``. Getting started --------------- -``pip install lastcast`` +``pip3 install lastcast`` Set up an initial configuration with the configuration creation tool: @@ -35,8 +35,8 @@ Detailed macOS setup Enter the following commands in your Terminal (Terminal.app, iTerm2, etc.): -1. ``sudo easy_install pip`` -2. ``sudo pip install --upgrade lastcast --ignore-installed six`` +1. ``brew install python3`` +2. ``sudo pip3 install --upgrade lastcast`` 3. ``lastcast --wizard`` This will prompt you to create a last.fm API application and then ask for your @@ -48,14 +48,10 @@ install xcode by running ``xcode-select --install`` and retry step 2. Now everything should be set up. When you want to start scrobbling, simply run ``lastcast`` in the terminal. -Generally, I run lastcast like so: ``while true; do lastcast; sleep 5; done``. -This will help in case lastcast crashes for whatever reason (please -open an issue if you see something go wrong!) - Linux / systemd instructions ---------------------------- -1. ``sudo pip install --upgrade lastcast`` +1. ``sudo pip3 install --upgrade lastcast`` 2. ``lastcast --wizard`` 3. Edit the code block below as needed (remember to fill in the config path!) and write to ``/usr/lib/systemd/system/lastcast.service`` From 9283f11b5813ed78e3bccdd52570b05c6bdbae46 Mon Sep 17 00:00:00 2001 From: Erik Price Date: Tue, 27 Feb 2018 22:42:22 -0800 Subject: [PATCH 5/5] Move macOS instructions down --- README.rst | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/README.rst b/README.rst index 7546523..04fda20 100644 --- a/README.rst +++ b/README.rst @@ -28,26 +28,6 @@ If you'd prefer to set up the configuration manually, modify Once the configuration file is in place, just run ``lastcast`` to connect to the Chromecast and start scrobbling! -Detailed macOS setup --------------------- - -(for anyone not familiar with Python and pip) - -Enter the following commands in your Terminal (Terminal.app, iTerm2, etc.): - -1. ``brew install python3`` -2. ``sudo pip3 install --upgrade lastcast`` -3. ``lastcast --wizard`` - -This will prompt you to create a last.fm API application and then ask for your -login information, which will only be stored locally on your computer. - -You may get an error on step 2 about ``cc`` missing. If this is the case, -install xcode by running ``xcode-select --install`` and retry step 2. - -Now everything should be set up. When you want to start scrobbling, simply -run ``lastcast`` in the terminal. - Linux / systemd instructions ---------------------------- @@ -74,6 +54,26 @@ Linux / systemd instructions WantedBy=network-online.target +Detailed macOS setup +-------------------- + +(for anyone not familiar with Python and pip) + +Enter the following commands in your Terminal (Terminal.app, iTerm2, etc.): + +1. ``brew install python3`` +2. ``sudo pip3 install --upgrade lastcast`` +3. ``lastcast --wizard`` + +This will prompt you to create a last.fm API application and then ask for your +login information, which will only be stored locally on your computer. + +You may get an error on step 2 about ``cc`` missing. If this is the case, +install xcode by running ``xcode-select --install`` and retry step 2. + +Now everything should be set up. When you want to start scrobbling, simply +run ``lastcast`` in the terminal. + No Chromecast devices found? ----------------------------