2017-01-09 14:21:54 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2017-04-15 00:47:59 +00:00
|
|
|
from datetime import datetime
|
2017-04-23 05:18:53 +00:00
|
|
|
from . import conftest as utils
|
2017-04-15 00:47:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_audio_Artist_attr(artist):
|
|
|
|
artist.reload()
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_datetime(artist.addedAt)
|
2017-04-15 00:47:59 +00:00
|
|
|
assert artist.countries == []
|
|
|
|
assert [i.tag for i in artist.genres] == ['Electronic']
|
2017-04-29 05:47:21 +00:00
|
|
|
assert utils.is_string(artist.guid, gte=5)
|
2017-04-15 00:47:59 +00:00
|
|
|
assert artist.index == '1'
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_metadata(artist._initpath)
|
|
|
|
assert utils.is_metadata(artist.key)
|
|
|
|
assert utils.is_int(artist.librarySectionID)
|
2017-04-15 00:47:59 +00:00
|
|
|
assert artist.listType == 'audio'
|
|
|
|
assert len(artist.locations) == 1
|
|
|
|
assert len(artist.locations[0]) >= 10
|
|
|
|
assert artist.ratingKey >= 1
|
2017-04-23 05:18:53 +00:00
|
|
|
assert artist._server._baseurl == utils.SERVER_BASEURL
|
2018-10-24 13:11:48 +00:00
|
|
|
assert [a.tag for a in artist.similar] == ['Kenneth Reitz'] # flaky?
|
2017-04-15 00:47:59 +00:00
|
|
|
assert artist.summary == ''
|
|
|
|
assert artist.title == 'Infinite State'
|
|
|
|
assert artist.titleSort == 'Infinite State'
|
|
|
|
assert artist.type == 'artist'
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_datetime(artist.updatedAt)
|
2017-04-29 05:47:21 +00:00
|
|
|
assert utils.is_int(artist.viewCount, gte=0)
|
2017-04-15 00:47:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_audio_Artist_get(artist, music):
|
|
|
|
artist == music.searchArtists(**{'title': 'Infinite State'})[0]
|
|
|
|
artist.title == 'Infinite State'
|
|
|
|
|
2017-01-09 14:21:54 +00:00
|
|
|
|
2017-04-15 00:47:59 +00:00
|
|
|
def test_audio_Artist_track(artist):
|
|
|
|
track = artist.track('Holy Moment')
|
2017-01-09 14:21:54 +00:00
|
|
|
assert track.title == 'Holy Moment'
|
|
|
|
|
|
|
|
|
2017-04-15 00:47:59 +00:00
|
|
|
def test_audio_Artist_tracks(artist):
|
|
|
|
tracks = artist.tracks()
|
2017-01-09 14:21:54 +00:00
|
|
|
assert len(tracks) == 14
|
|
|
|
|
|
|
|
|
2017-04-15 00:47:59 +00:00
|
|
|
def test_audio_Artist_album(artist):
|
|
|
|
album = artist.album('Unmastered Impulses')
|
2017-01-09 14:21:54 +00:00
|
|
|
assert album.title == 'Unmastered Impulses'
|
|
|
|
|
|
|
|
|
2017-04-15 00:47:59 +00:00
|
|
|
def test_audio_Artist_albums(artist):
|
|
|
|
albums = artist.albums()
|
2017-01-09 14:21:54 +00:00
|
|
|
assert len(albums) == 1 and albums[0].title == 'Unmastered Impulses'
|
|
|
|
|
|
|
|
|
2017-04-15 00:47:59 +00:00
|
|
|
def test_audio_Album_attrs(album):
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_datetime(album.addedAt)
|
2017-04-15 00:47:59 +00:00
|
|
|
assert [i.tag for i in album.genres] == ['Electronic']
|
|
|
|
assert album.index == '1'
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_metadata(album._initpath)
|
|
|
|
assert utils.is_metadata(album.key)
|
|
|
|
assert utils.is_int(album.librarySectionID)
|
2017-04-15 00:47:59 +00:00
|
|
|
assert album.listType == 'audio'
|
|
|
|
assert album.originallyAvailableAt == datetime(2016, 1, 1)
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_metadata(album.parentKey)
|
|
|
|
assert utils.is_int(album.parentRatingKey)
|
2017-04-23 05:54:53 +00:00
|
|
|
if album.parentThumb:
|
|
|
|
assert utils.is_metadata(album.parentThumb, contains='/thumb/')
|
2017-04-15 00:47:59 +00:00
|
|
|
assert album.parentTitle == 'Infinite State'
|
|
|
|
assert album.ratingKey >= 1
|
2017-04-23 05:18:53 +00:00
|
|
|
assert album._server._baseurl == utils.SERVER_BASEURL
|
2017-04-15 00:47:59 +00:00
|
|
|
assert album.studio is None
|
|
|
|
assert album.summary == ''
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_metadata(album.thumb, contains='/thumb/')
|
2017-04-15 00:47:59 +00:00
|
|
|
assert album.title == 'Unmastered Impulses'
|
|
|
|
assert album.titleSort == 'Unmastered Impulses'
|
|
|
|
assert album.type == 'album'
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_datetime(album.updatedAt)
|
2017-04-29 05:47:21 +00:00
|
|
|
assert utils.is_int(album.viewCount, gte=0)
|
2017-04-15 00:47:59 +00:00
|
|
|
assert album.year == 2016
|
2017-11-08 21:01:53 +00:00
|
|
|
assert album.artUrl is None
|
2017-04-15 00:47:59 +00:00
|
|
|
|
|
|
|
def test_audio_Album_tracks(album):
|
|
|
|
tracks = album.tracks()
|
|
|
|
track = tracks[0]
|
2017-01-09 14:21:54 +00:00
|
|
|
assert len(tracks) == 14
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_metadata(track.grandparentKey)
|
|
|
|
assert utils.is_int(track.grandparentRatingKey)
|
2017-04-15 00:47:59 +00:00
|
|
|
assert track.grandparentTitle == 'Infinite State'
|
|
|
|
assert track.index == '1'
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_metadata(track._initpath)
|
|
|
|
assert utils.is_metadata(track.key)
|
2017-04-15 00:47:59 +00:00
|
|
|
assert track.listType == 'audio'
|
|
|
|
assert track.originalTitle == 'Kenneth Reitz'
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_int(track.parentIndex)
|
|
|
|
assert utils.is_metadata(track.parentKey)
|
|
|
|
assert utils.is_int(track.parentRatingKey)
|
|
|
|
assert utils.is_metadata(track.parentThumb, contains='/thumb/')
|
2017-04-15 00:47:59 +00:00
|
|
|
assert track.parentTitle == 'Unmastered Impulses'
|
|
|
|
assert track.ratingCount == 9
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_int(track.ratingKey)
|
|
|
|
assert track._server._baseurl == utils.SERVER_BASEURL
|
2017-04-15 00:47:59 +00:00
|
|
|
assert track.summary == ""
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_metadata(track.thumb, contains='/thumb/')
|
2017-04-15 00:47:59 +00:00
|
|
|
assert track.title == 'Holy Moment'
|
|
|
|
assert track.titleSort == 'Holy Moment'
|
2017-10-13 22:02:21 +00:00
|
|
|
assert not track.transcodeSessions
|
2017-04-15 00:47:59 +00:00
|
|
|
assert track.type == 'track'
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_datetime(track.updatedAt)
|
2017-04-29 05:47:21 +00:00
|
|
|
assert utils.is_int(track.viewCount, gte=0)
|
2017-04-15 00:47:59 +00:00
|
|
|
assert track.viewOffset == 0
|
|
|
|
|
|
|
|
|
|
|
|
def test_audio_Album_track(album, track=None):
|
2017-01-09 14:21:54 +00:00
|
|
|
# this is not reloaded. its not that much info missing.
|
2017-04-15 00:47:59 +00:00
|
|
|
track = track or album.track('Holy Moment')
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_datetime(track.addedAt)
|
2017-01-09 14:21:54 +00:00
|
|
|
assert track.duration == 298606
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_metadata(track.grandparentKey)
|
|
|
|
assert utils.is_int(track.grandparentRatingKey)
|
2017-01-09 14:21:54 +00:00
|
|
|
assert track.grandparentTitle == 'Infinite State'
|
2017-04-15 00:47:59 +00:00
|
|
|
assert int(track.index) == 1
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_metadata(track._initpath)
|
|
|
|
assert utils.is_metadata(track.key)
|
2017-01-09 14:21:54 +00:00
|
|
|
assert track.listType == 'audio'
|
|
|
|
# Assign 0 track.media
|
2017-04-15 00:47:59 +00:00
|
|
|
media = track.media[0]
|
2017-01-09 14:21:54 +00:00
|
|
|
assert track.originalTitle == 'Kenneth Reitz'
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_int(track.parentIndex)
|
|
|
|
assert utils.is_metadata(track.parentKey)
|
|
|
|
assert utils.is_int(track.parentRatingKey)
|
|
|
|
assert utils.is_metadata(track.parentThumb, contains='/thumb/')
|
2017-01-09 14:21:54 +00:00
|
|
|
assert track.parentTitle == 'Unmastered Impulses'
|
|
|
|
assert track.ratingCount == 9
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_int(track.ratingKey)
|
|
|
|
assert track._server._baseurl == utils.SERVER_BASEURL
|
2017-01-09 14:21:54 +00:00
|
|
|
assert track.summary == ''
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_metadata(track.thumb, contains='/thumb/')
|
2017-01-09 14:21:54 +00:00
|
|
|
assert track.title == 'Holy Moment'
|
|
|
|
assert track.titleSort == 'Holy Moment'
|
2017-10-13 22:02:21 +00:00
|
|
|
assert not track.transcodeSessions
|
2017-01-09 14:21:54 +00:00
|
|
|
assert track.type == 'track'
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_datetime(track.updatedAt)
|
2017-04-29 05:47:21 +00:00
|
|
|
assert utils.is_int(track.viewCount, gte=0)
|
2017-01-09 14:21:54 +00:00
|
|
|
assert track.viewOffset == 0
|
2017-04-15 00:47:59 +00:00
|
|
|
assert media.aspectRatio is None
|
|
|
|
assert media.audioChannels == 2
|
|
|
|
assert media.audioCodec == 'mp3'
|
|
|
|
assert media.bitrate == 385
|
|
|
|
assert media.container == 'mp3'
|
|
|
|
assert media.duration == 298606
|
|
|
|
assert media.height is None
|
2017-04-29 05:47:21 +00:00
|
|
|
assert utils.is_int(media.id, gte=1)
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_metadata(media._initpath)
|
2017-04-15 00:47:59 +00:00
|
|
|
assert media.optimizedForStreaming is None
|
|
|
|
# Assign 0 media.parts
|
|
|
|
part = media.parts[0]
|
2017-04-23 05:18:53 +00:00
|
|
|
assert media._server._baseurl == utils.SERVER_BASEURL
|
2017-04-15 00:47:59 +00:00
|
|
|
assert media.videoCodec is None
|
|
|
|
assert media.videoFrameRate is None
|
|
|
|
assert media.videoResolution is None
|
|
|
|
assert media.width is None
|
|
|
|
assert part.container == 'mp3'
|
|
|
|
assert part.duration == 298606
|
|
|
|
assert part.file.endswith('.mp3')
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_int(part.id)
|
|
|
|
assert utils.is_metadata(part._initpath)
|
|
|
|
assert utils.is_part(part.key)
|
|
|
|
assert part._server._baseurl == utils.SERVER_BASEURL
|
2017-04-15 00:47:59 +00:00
|
|
|
assert part.size == 14360402
|
2017-11-08 21:01:53 +00:00
|
|
|
assert track.artUrl is None
|
2017-04-15 00:47:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_audio_Album_get(album):
|
|
|
|
# alias for album.track()
|
|
|
|
track = album.get('Holy Moment')
|
|
|
|
test_audio_Album_track(album, track=track)
|
|
|
|
|
|
|
|
|
|
|
|
def test_audio_Album_artist(album):
|
|
|
|
artist = album.artist()
|
2017-01-09 14:21:54 +00:00
|
|
|
artist.title == 'Infinite State'
|
|
|
|
|
|
|
|
|
2017-04-15 00:47:59 +00:00
|
|
|
def test_audio_Track_attrs(album):
|
|
|
|
track = album.get('Holy Moment').reload()
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_datetime(track.addedAt)
|
2017-02-04 19:18:10 +00:00
|
|
|
assert track.art is None
|
|
|
|
assert track.chapterSource is None
|
2017-01-09 14:21:54 +00:00
|
|
|
assert track.duration == 298606
|
2017-02-04 19:18:10 +00:00
|
|
|
assert track.grandparentArt is None
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_metadata(track.grandparentKey)
|
|
|
|
assert utils.is_int(track.grandparentRatingKey)
|
2017-04-23 05:54:53 +00:00
|
|
|
if track.grandparentThumb:
|
|
|
|
assert utils.is_metadata(track.grandparentThumb, contains='/thumb/')
|
2017-01-09 14:21:54 +00:00
|
|
|
assert track.grandparentTitle == 'Infinite State'
|
2017-04-15 00:47:59 +00:00
|
|
|
assert track.guid.startswith('local://')
|
|
|
|
assert int(track.index) == 1
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_metadata(track._initpath)
|
|
|
|
assert utils.is_metadata(track.key)
|
2017-04-29 06:21:20 +00:00
|
|
|
if track.lastViewedAt:
|
|
|
|
assert utils.is_datetime(track.lastViewedAt)
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_int(track.librarySectionID)
|
2017-01-09 14:21:54 +00:00
|
|
|
assert track.listType == 'audio'
|
|
|
|
# Assign 0 track.media
|
2017-04-15 00:47:59 +00:00
|
|
|
media = track.media[0]
|
2017-01-09 14:21:54 +00:00
|
|
|
assert track.moods == []
|
|
|
|
assert track.originalTitle == 'Kenneth Reitz'
|
2017-04-15 00:47:59 +00:00
|
|
|
assert int(track.parentIndex) == 1
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_metadata(track.parentKey)
|
|
|
|
assert utils.is_int(track.parentRatingKey)
|
|
|
|
assert utils.is_metadata(track.parentThumb, contains='/thumb/')
|
2017-01-09 14:21:54 +00:00
|
|
|
assert track.parentTitle == 'Unmastered Impulses'
|
2017-02-04 19:18:10 +00:00
|
|
|
assert track.playlistItemID is None
|
|
|
|
assert track.primaryExtraKey is None
|
2017-01-09 14:21:54 +00:00
|
|
|
assert track.ratingCount == 9
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_int(track.ratingKey)
|
|
|
|
assert track._server._baseurl == utils.SERVER_BASEURL
|
2017-02-04 19:18:10 +00:00
|
|
|
assert track.sessionKey is None
|
2017-01-09 14:21:54 +00:00
|
|
|
assert track.summary == ''
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_metadata(track.thumb, contains='/thumb/')
|
2017-01-09 14:21:54 +00:00
|
|
|
assert track.title == 'Holy Moment'
|
|
|
|
assert track.titleSort == 'Holy Moment'
|
2017-10-13 22:02:21 +00:00
|
|
|
assert not track.transcodeSessions
|
2017-01-09 14:21:54 +00:00
|
|
|
assert track.type == 'track'
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_datetime(track.updatedAt)
|
2017-04-29 05:47:21 +00:00
|
|
|
assert utils.is_int(track.viewCount, gte=0)
|
2017-01-09 14:21:54 +00:00
|
|
|
assert track.viewOffset == 0
|
2017-02-04 19:18:10 +00:00
|
|
|
assert track.viewedAt is None
|
|
|
|
assert track.year is None
|
2017-04-15 00:47:59 +00:00
|
|
|
assert media.aspectRatio is None
|
|
|
|
assert media.audioChannels == 2
|
|
|
|
assert media.audioCodec == 'mp3'
|
|
|
|
assert media.bitrate == 385
|
|
|
|
assert media.container == 'mp3'
|
|
|
|
assert media.duration == 298606
|
|
|
|
assert media.height is None
|
2017-04-29 05:47:21 +00:00
|
|
|
assert utils.is_int(media.id, gte=1)
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_metadata(media._initpath)
|
2017-04-15 00:47:59 +00:00
|
|
|
assert media.optimizedForStreaming is None
|
|
|
|
# Assign 0 media.parts
|
|
|
|
part = media.parts[0]
|
2017-04-23 05:18:53 +00:00
|
|
|
assert media._server._baseurl == utils.SERVER_BASEURL
|
2017-04-15 00:47:59 +00:00
|
|
|
assert media.videoCodec is None
|
|
|
|
assert media.videoFrameRate is None
|
|
|
|
assert media.videoResolution is None
|
|
|
|
assert media.width is None
|
|
|
|
assert part.container == 'mp3'
|
|
|
|
assert part.duration == 298606
|
|
|
|
assert part.file.endswith('.mp3')
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_int(part.id)
|
|
|
|
assert utils.is_metadata(part._initpath)
|
|
|
|
assert utils.is_part(part.key)
|
2017-04-15 00:47:59 +00:00
|
|
|
#assert part.media == <Media:Holy.Moment>
|
2017-04-23 05:18:53 +00:00
|
|
|
assert part._server._baseurl == utils.SERVER_BASEURL
|
2017-04-15 00:47:59 +00:00
|
|
|
assert part.size == 14360402
|
|
|
|
# Assign 0 part.streams
|
|
|
|
stream = part.streams[0]
|
|
|
|
assert stream.audioChannelLayout == 'stereo'
|
|
|
|
assert stream.bitDepth is None
|
|
|
|
assert stream.bitrate == 320
|
|
|
|
assert stream.bitrateMode is None
|
|
|
|
assert stream.channels == 2
|
|
|
|
assert stream.codec == 'mp3'
|
|
|
|
assert stream.codecID is None
|
|
|
|
assert stream.dialogNorm is None
|
|
|
|
assert stream.duration is None
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_int(stream.id)
|
2017-04-15 00:47:59 +00:00
|
|
|
assert stream.index == 0
|
2017-04-23 05:18:53 +00:00
|
|
|
assert utils.is_metadata(stream._initpath)
|
2017-04-15 00:47:59 +00:00
|
|
|
assert stream.language is None
|
|
|
|
assert stream.languageCode is None
|
|
|
|
#assert stream.part == <MediaPart:22>
|
|
|
|
assert stream.samplingRate == 44100
|
|
|
|
assert stream.selected is True
|
2017-04-23 05:18:53 +00:00
|
|
|
assert stream._server._baseurl == utils.SERVER_BASEURL
|
2017-04-15 00:47:59 +00:00
|
|
|
assert stream.streamType == 2
|
|
|
|
assert stream.title is None
|
|
|
|
assert stream.type == 2
|
|
|
|
|
|
|
|
|
|
|
|
def test_audio_Track_album(album):
|
|
|
|
tracks = album.tracks()
|
|
|
|
assert tracks[0].album() == album
|
|
|
|
|
|
|
|
|
|
|
|
def test_audio_Track_artist(album, artist):
|
|
|
|
tracks = album.tracks()
|
|
|
|
assert tracks[0].artist() == artist
|
|
|
|
|
|
|
|
|
|
|
|
def test_audio_Audio_section(artist, album, track):
|
|
|
|
assert artist.section()
|
|
|
|
assert album.section()
|
|
|
|
assert track.section()
|
|
|
|
assert track.section().key == album.section().key == artist.section().key
|
|
|
|
|
|
|
|
|
|
|
|
def test_audio_Track_download(monkeydownload, tmpdir, track):
|
|
|
|
f = track.download(savepath=str(tmpdir))
|
2017-01-09 14:21:54 +00:00
|
|
|
assert f
|
|
|
|
|
|
|
|
|
2017-04-15 00:47:59 +00:00
|
|
|
def test_audio_album_download(monkeydownload, album, tmpdir):
|
|
|
|
f = album.download(savepath=str(tmpdir))
|
2017-01-09 14:21:54 +00:00
|
|
|
assert len(f) == 14
|
|
|
|
|
|
|
|
|
2017-04-15 00:47:59 +00:00
|
|
|
def test_audio_Artist_download(monkeydownload, artist, tmpdir):
|
|
|
|
f = artist.download(savepath=str(tmpdir))
|
2017-01-09 14:21:54 +00:00
|
|
|
assert len(f) == 14
|
2018-03-02 10:41:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_audio_Album_label(album, patched_http_call):
|
|
|
|
album.addLabel('YO')
|