Repository: postlund/pyatv

Issue:
Unknown media kind TV show
The media kind "TV Show" is not recognized correctly.
pyatv.exceptions.UnknownMediaKind: Unknown media kind: 64

Discussion:
coveralls: 
[![Coverage Status](https://coveralls.io/builds/10544411/badge)](https://coveralls.io/builds/10544411)

Coverage remained the same at 96.547% when pulling **a138f1ea040fec310dbb8629f57194a7ed97ce7b on media_kinds** into **8937e869c3ce7d86edad5d2c88d2139fe57c3127 on master**.


Patch:
diff --git a/pyatv/convert.py b/pyatv/convert.py
index 98c7e77e..0843f19b 100644
--- a/pyatv/convert.py
+++ b/pyatv/convert.py
@@ -7,11 +7,11 @@ def media_kind(kind):
     """Convert iTunes media kind to API representation."""
     if kind in [1]:
         return const.MEDIA_TYPE_UNKNOWN
-    elif kind in [3, 7, 11, 12, 13, 18]:
+    elif kind in [3, 7, 11, 12, 13, 18, 32]:
         return const.MEDIA_TYPE_VIDEO
-    elif kind in [2, 4, 10, 14, 17, 21]:
+    elif kind in [2, 4, 10, 14, 17, 21, 36]:
         return const.MEDIA_TYPE_MUSIC
-    elif kind in [8]:
+    elif kind in [8, 64]:
         return const.MEDIA_TYPE_TV
 
     raise exceptions.UnknownMediaKind('Unknown media kind: ' + str(kind))


Test patch:
diff --git a/tests/test_convert.py b/tests/test_convert.py
index 99d8bdd3..77dfab2e 100644
--- a/tests/test_convert.py
+++ b/tests/test_convert.py
@@ -6,6 +6,8 @@ from pyatv import (const, convert, exceptions)
 
 # These are extracted from iTunes, see for instance:
 # http://www.blooming.no/wp-content/uploads/2013/03/ITLibMediaItem.h
+# and also this:
+# https://github.com/melloware/dacp-net/blob/master/Melloware.DACP/DACPResponse.cs
 # Key: cmst.cmmk
 MEDIA_KIND_UNKNOWN = 1
 MEDIA_KIND_SONG = 2
@@ -28,7 +30,9 @@ MEDIA_KIND_ITUNESU = 18
 MEDIA_KIND_BOOK = 19
 MEDIA_KIND_PDFBOOK = 20
 MEDIA_KIND_ALERTTONE = 21
-
+MEDIA_KIND_MUSICVIDEO2 = 32
+MEDIA_KIND_PODCAST2 = 36
+MEDIA_KIND_TVSHOW2 = 64
 
 # Found on various places on the Internet as well as by testing
 # Key: cmst.caps
@@ -52,6 +56,8 @@ class ConvertTest(unittest.TestCase):
                          convert.media_kind(MEDIA_KIND_MOVIE))
         self.assertEqual(const.MEDIA_TYPE_VIDEO,
                          convert.media_kind(MEDIA_KIND_MUSICVIDEO))
+        self.assertEqual(const.MEDIA_TYPE_VIDEO,
+                         convert.media_kind(MEDIA_KIND_MUSICVIDEO2))
         self.assertEqual(const.MEDIA_TYPE_VIDEO,
                          convert.media_kind(MEDIA_KIND_VIDEOPASS))
         self.assertEqual(const.MEDIA_TYPE_VIDEO,
@@ -66,6 +72,8 @@ class ConvertTest(unittest.TestCase):
                          convert.media_kind(MEDIA_KIND_SONG))
         self.assertEqual(const.MEDIA_TYPE_MUSIC,
                          convert.media_kind(MEDIA_KIND_PODCAST))
+        self.assertEqual(const.MEDIA_TYPE_MUSIC,
+                         convert.media_kind(MEDIA_KIND_PODCAST2))
         self.assertEqual(const.MEDIA_TYPE_MUSIC,
                          convert.media_kind(MEDIA_KIND_COACHEDAUDIO))
         self.assertEqual(const.MEDIA_TYPE_MUSIC,
@@ -78,6 +86,8 @@ class ConvertTest(unittest.TestCase):
     def test_tv_kinds(self):
         self.assertEqual(const.MEDIA_TYPE_TV,
                          convert.media_kind(MEDIA_KIND_TVSHOW))
+        self.assertEqual(const.MEDIA_TYPE_TV,
+                         convert.media_kind(MEDIA_KIND_TVSHOW2))
 
     def test_unknown_media_kind_throws(self):
         with self.assertRaises(exceptions.UnknownMediaKind):