mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 02:06:09 +00:00
Infer values for musicvideo "track" and "premiered" fields... (#109)
* Infer values for musicvideo track and premiered fields when none are available from Emby, to support some kodi views. * Tidy up some code style issues
This commit is contained in:
parent
9803e9dcdf
commit
aaeb3a6272
2 changed files with 21 additions and 6 deletions
|
@ -43,9 +43,9 @@ class KodiMusicVideos(KodiItems):
|
||||||
query = (
|
query = (
|
||||||
'''
|
'''
|
||||||
INSERT INTO musicvideo(
|
INSERT INTO musicvideo(
|
||||||
idMVideo, idFile, c00, c04, c05, c06, c07, c08, c09, c10, c11, c12)
|
idMVideo, idFile, c00, c04, c05, c06, c07, c08, c09, c10, c11, c12, premiered)
|
||||||
|
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
self.cursor.execute(query, (args))
|
self.cursor.execute(query, (args))
|
||||||
|
@ -56,7 +56,7 @@ class KodiMusicVideos(KodiItems):
|
||||||
|
|
||||||
"UPDATE musicvideo",
|
"UPDATE musicvideo",
|
||||||
"SET c00 = ?, c04 = ?, c05 = ?, c06 = ?, c07 = ?, c08 = ?, c09 = ?, c10 = ?,",
|
"SET c00 = ?, c04 = ?, c05 = ?, c06 = ?, c07 = ?, c08 = ?, c09 = ?, c10 = ?,",
|
||||||
"c11 = ?, c12 = ?"
|
"c11 = ?, c12 = ?, premiered = ?"
|
||||||
"WHERE idMVideo = ?"
|
"WHERE idMVideo = ?"
|
||||||
))
|
))
|
||||||
self.cursor.execute(query, (args))
|
self.cursor.execute(query, (args))
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import urllib
|
import urllib
|
||||||
|
import datetime
|
||||||
|
import re
|
||||||
|
|
||||||
import api
|
import api
|
||||||
import embydb_functions as embydb
|
import embydb_functions as embydb
|
||||||
|
@ -133,6 +135,12 @@ class MusicVideos(Items):
|
||||||
plot = API.get_overview()
|
plot = API.get_overview()
|
||||||
title = item['Name']
|
title = item['Name']
|
||||||
year = item.get('ProductionYear')
|
year = item.get('ProductionYear')
|
||||||
|
# Some kodi views/skins rely on the "premiered" field to display by year.
|
||||||
|
# So, if we don't get the premiere date from Emby, just set it to Jan 1st
|
||||||
|
# of the video's "year", so that Kodi has a year to work with.
|
||||||
|
premiered = item.get('PremiereDate')
|
||||||
|
if premiered is None and year is not None:
|
||||||
|
premiered = datetime.date(year, 1, 1)
|
||||||
genres = item['Genres']
|
genres = item['Genres']
|
||||||
genre = " / ".join(genres)
|
genre = " / ".join(genres)
|
||||||
studios = API.get_studios()
|
studios = API.get_studios()
|
||||||
|
@ -140,10 +148,17 @@ class MusicVideos(Items):
|
||||||
artist = " / ".join(item.get('Artists'))
|
artist = " / ".join(item.get('Artists'))
|
||||||
album = item.get('Album')
|
album = item.get('Album')
|
||||||
track = item.get('Track')
|
track = item.get('Track')
|
||||||
|
# If we don't get the track number from Emby, see if we can infer it
|
||||||
|
# from the sortname attribute.
|
||||||
|
if track is None:
|
||||||
|
sortname = item.get('SortName')
|
||||||
|
if sortname is not None:
|
||||||
|
search = re.search(r'^\d+\s?', sortname)
|
||||||
|
if search is not None:
|
||||||
|
track = search.group()
|
||||||
people = API.get_people()
|
people = API.get_people()
|
||||||
director = " / ".join(people['Director'])
|
director = " / ".join(people['Director'])
|
||||||
|
|
||||||
|
|
||||||
##### GET THE FILE AND PATH #####
|
##### GET THE FILE AND PATH #####
|
||||||
playurl = API.get_file_path()
|
playurl = API.get_file_path()
|
||||||
|
|
||||||
|
@ -179,7 +194,7 @@ class MusicVideos(Items):
|
||||||
|
|
||||||
# Update the music video entry
|
# Update the music video entry
|
||||||
self.kodi_db.update_musicvideo(title, runtime, director, studio, year, plot, album,
|
self.kodi_db.update_musicvideo(title, runtime, director, studio, year, plot, album,
|
||||||
artist, genre, track, mvideoid)
|
artist, genre, track, premiered, mvideoid)
|
||||||
|
|
||||||
# Update the checksum in emby table
|
# Update the checksum in emby table
|
||||||
emby_db.updateReference(itemid, checksum)
|
emby_db.updateReference(itemid, checksum)
|
||||||
|
@ -195,7 +210,7 @@ class MusicVideos(Items):
|
||||||
|
|
||||||
# Create the musicvideo entry
|
# Create the musicvideo entry
|
||||||
self.kodi_db.add_musicvideo(mvideoid, fileid, title, runtime, director, studio,
|
self.kodi_db.add_musicvideo(mvideoid, fileid, title, runtime, director, studio,
|
||||||
year, plot, album, artist, genre, track)
|
year, plot, album, artist, genre, track, premiered)
|
||||||
|
|
||||||
# Create the reference in emby table
|
# Create the reference in emby table
|
||||||
emby_db.addReference(itemid, mvideoid, "MusicVideo", "musicvideo", fileid, pathid,
|
emby_db.addReference(itemid, mvideoid, "MusicVideo", "musicvideo", fileid, pathid,
|
||||||
|
|
Loading…
Reference in a new issue