-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update scrobble_cache to use Pickle instead of Shelve. * encode values returned from ETree to 'utf-8' in fetch_metadata * Add tests to mock respones from fetch_metadata * More Python 3 clean-up * Swap file open to io.open to we can force encoding='utf-8' on reads. * Adding mutex locks on scrobble_cache access.
- Loading branch information
Showing
8 changed files
with
139 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,26 +2,27 @@ | |
from setuptools import setup | ||
|
||
NAME = 'plex-lastfm-scrobbler' | ||
VERSION = '3.0.0' | ||
VERSION = '4.0.0' | ||
|
||
setup( | ||
name = 'plex_scrobble', | ||
version = VERSION, | ||
author = 'Jesse Ward', | ||
author_email = '[email protected]', | ||
description = ('Scrobble audio tracks played via Plex Media Center'), | ||
license = 'MIT', | ||
url = 'https://github.com/jesseward/plex-lastfm-scrobbler', | ||
name='plex_scrobble', | ||
version=VERSION, | ||
author='Jesse Ward', | ||
author_email='[email protected]', | ||
description=('Scrobble audio tracks played via Plex Media Center'), | ||
license='MIT', | ||
url='https://github.com/jesseward/plex-lastfm-scrobbler', | ||
packages=['plex_scrobble'], | ||
entry_points={ | ||
'console_scripts': [ | ||
'plex-scrobble = plex_scrobble.__main__:main' | ||
] | ||
'console_scripts': [ | ||
'plex-scrobble = plex_scrobble.__main__:main' | ||
] | ||
}, | ||
install_requires=[ | ||
'click>=6.2', | ||
'pylast>=1.6.0', | ||
'toml>=0.9.1', | ||
'requests>=2.12.0', | ||
'mock>=2.0.0', | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<MediaContainer size="1" allowSync="1" identifier="com.plexapp.plugins.library" librarySectionID="2" librarySectionTitle="Music" librarySectionUUID="aaaaaaaa-1234-aaaa-aaaa-123451234512" mediaTagPrefix="/system/bundle/media/flags/" mediaTagVersion="1486068602"> | ||
<Track ratingKey="538" key="/library/metadata/538" parentRatingKey="537" grandparentRatingKey="524" guid="com.plexapp.agents.plexmusic://gracenote/track/431995094-D73A524D5EE92E857CCCDB331E0911D0/444891092-70D20C5F59D82102B7B91FCD4A41E1C6?lang=en" librarySectionID="2" type="track" title="daze" grandparentKey="/library/metadata/524" parentKey="/library/metadata/537" grandparentTitle="じん(自然の敵P)" parentTitle="daze / days" originalTitle="じん Feat. メイリア" summary="" index="1" parentIndex="1" viewCount="1" lastViewedAt="1486331020" year="2014" thumb="/library/metadata/537/thumb/1486266973" parentThumb="/library/metadata/537/thumb/1486266973" grandparentThumb="/library/metadata/524/thumb/1486266954" duration="235502" addedAt="1486266669" updatedAt="1486266973"> | ||
<Media id="438" duration="235502" bitrate="4621" audioChannels="2" audioCodec="flac" container="flac"> | ||
<Part id="438" key="/library/parts/438/1486266413/file.flac" duration="235502" file="/path/to/file/01. daze.flac" size="136024317" container="flac"> | ||
<Stream id="766" streamType="2" selected="1" codec="flac" index="0" channels="2" bitrate="4621" audioChannelLayout="stereo" bitDepth="24" samplingRate="96000" /> | ||
</Part> | ||
</Media> | ||
</Track> | ||
</MediaContainer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
import io | ||
import unittest | ||
|
||
from mock import patch | ||
|
||
from config import config | ||
from plex_scrobble.plex_monitor import fetch_metadata | ||
|
||
|
||
class TestFetchMetaData(unittest.TestCase): | ||
|
||
def test_fetch_metadata_unicode(self): | ||
""" Validates parsing of response data from the PMS metadata API. """ | ||
|
||
with patch('plex_scrobble.plex_monitor.requests.get') as mock_get: | ||
with io.open('data/unicode_audio_payload_fetch_metadata.xml', 'r', encoding='utf-8') as fh: | ||
mock_get.return_value.text = fh.read() | ||
metadata = fetch_metadata(64738, config) | ||
|
||
self.assertEqual(metadata['artist'], b'\xe3\x81\x98\xe3\x82\x93 Feat. \xe3\x83\xa1\xe3\x82\xa4\xe3\x83\xaa\xe3\x82\xa2') | ||
self.assertEqual(metadata['album'], b'daze / days') | ||
self.assertEqual(metadata['title'], b'daze') | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters