diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py
index cab6fe3c..23f99e52 100644
--- a/resources/lib/itemtypes.py
+++ b/resources/lib/itemtypes.py
@@ -2280,10 +2280,14 @@ class Music(Items):
             # Add path
             pathid = kodi_db.addPath(path)
 
-            # Get the album
-            emby_dbalbum = emby_db.getItem_byId(item['AlbumId'])
             try:
+                # Get the album
+                emby_dbalbum = emby_db.getItem_byId(item['AlbumId'])
                 albumid = emby_dbalbum[0]
+            except KeyError:
+                # No album Id associated to the song.
+                self.logMsg("Song itemid: %s has no albumId." % itemid, 1)
+                return
             except TypeError:
                 # No album found, create a single's album
                 kodicursor.execute("select coalesce(max(idAlbum),0) from album")
diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py
index e5cacfab..7f9f4efe 100644
--- a/resources/lib/librarysync.py
+++ b/resources/lib/librarysync.py
@@ -358,7 +358,7 @@ class LibrarySync(threading.Thread):
                     # Media folders are grouped into userview
                     for grouped_view in grouped_views:
                         if (grouped_view['Type'] == "UserView" and 
-                            grouped_view['CollectionType'] == mediatype):
+                            grouped_view.get('CollectionType') == mediatype):
                             # Take the name of the userview
                             foldername = grouped_view['Name']
                             break