Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload collection metadata #117

Closed
agneevX opened this issue Mar 4, 2021 · 26 comments · Fixed by #366 or #407
Closed

Upload collection metadata #117

agneevX opened this issue Mar 4, 2021 · 26 comments · Fixed by #366 or #407
Labels
help wanted Extra attention is needed

Comments

@agneevX
Copy link
Contributor

agneevX commented Mar 4, 2021

It would be nice if metadata support for collections were added.

Current With metadata support
image image
@glensc
Copy link
Collaborator

glensc commented Apr 8, 2021

@agneevX please explain what do you mean. scrobble in my dictionary means to use "user is watching x"

movie play scrobbling is possible with watch subcommand since:

tv episode scrobbling does not work yet

@simonc56
Copy link
Collaborator

simonc56 commented Apr 9, 2021

metadata = picture definition (720p, 1080p,...), audio channels and codec, etc...

@glensc
Copy link
Collaborator

glensc commented Apr 9, 2021

ok, seems it's about this feature:

but can't find any method from trakt library we are using to support this. is there public api for this?

@glensc
Copy link
Collaborator

glensc commented Apr 9, 2021

found the api doc:

@agneevX agneevX changed the title Scrobble collection metadata Upload collection metadata Apr 9, 2021
@agneevX
Copy link
Contributor Author

agneevX commented Apr 9, 2021

Sorry, I misunderstood the definition of "scrobble" 😅

@agneevX
Copy link
Contributor Author

agneevX commented Apr 9, 2021

Worth noting is that the Plex-trakt-scrobbler doesn't support Format and HDR parameters; it defaults to Digital and No respectively.

This info can perhaps be retrieved from the file name and analyzed metadata perhaps.

@glensc
Copy link
Collaborator

glensc commented Apr 9, 2021

adding missing link:

@agneevX please link to resources you are talking about!

@glensc
Copy link
Collaborator

glensc commented Apr 9, 2021

support from trakt library we are using is missing:

@glensc
Copy link
Collaborator

glensc commented Apr 9, 2021

I was able to make up these fields:

    def to_json(self):
        return {
            "collected_at": timestamp(self.collected_at),
            "media_type": "digital",
            "resolution": self.resolution,
            # "hdr": "dolby_vision",
            # "audio": "dts_ma",
            "audio_channels": self.audio_channels,
        }

@glensc
Copy link
Collaborator

glensc commented Apr 9, 2021

for audio channels, need exact values from plex side for these:

Set to 1.0, 2.0, 2.1, 3.0, 3.1, 4.0, 4.1, 5.0, 5.1, 5.1.2, 5.1.4, 6.1, 7.1, 7.1.2, 7.1.4, 9.1, or 10.1

trakt was so picky, that it gave 500 error if for audio channels was submitted 2, not "2.0"

the same for videos, need plex side values for:

Set to uhd_4k, hd_1080p, hd_1080i, hd_720p, sd_480p, sd_480i, sd_576p, or sd_576i.

And audio format:

Set to dolby_digital, dolby_digital_plus, dolby_digital_plus_atmos, dolby_truehd, dolby_atmos (Dolby TrueHD Atmos), dolby_prologic, dts, dts_ma, dts_hr, dts_x, auro_3d, mp3, mp2, aac, lpcm, ogg (Ogg Vorbis), ogg_opus, wma, or flac.


dirty code is here now: #211, maybe moved out soon, as that pr is for collected_at field only. and the PR is for movies only right now.

@glensc
Copy link
Collaborator

glensc commented Apr 10, 2021

so, @agneevX (and others), if you want to progress this faster, you can help by finding values to use for re-mapping.

Maybe there's simpler, easier to find, but there's XML files in:

  • Library/Application Support/Plex Media Server/Metadata

they contain lines like:

<Stream index="1" selected="1" streamType="2" channels="2" codec="aac" languageCode="en" id="2"/>

@glensc
Copy link
Collaborator

glensc commented Apr 10, 2021

Changes for only this issue are here now:

@agneevX
Copy link
Contributor Author

agneevX commented Apr 10, 2021

@glensc I'm not exactly sure what it is you want me to do... do you want me to provide stream metadata info for media in my library?

@agneevX
Copy link
Contributor Author

agneevX commented Apr 10, 2021

If so, I hope these help.

Dolby Vision 4K w/ E-AC3/DDP+ + Dolby Atmos audio

<Stream id="471182" streamType="1" default="1" codec="hevc" index="0" bitrate="21842" DOVIBLCompatID="0" DOVIBLPresent="1" DOVIELPresent="0" DOVILevel="6" DOVIPresent="1" DOVIProfile="5" DOVIRPUPresent="1" DOVIVersion="1.0" bitDepth="10" chromaSubsampling="4:2:0" codecID="dvhe" codedHeight="2160" codedWidth="3840" colorRange="pc" frameRate="23.976" height="2160" level="156" profile="main 10" refFrames="1" streamIdentifier="1" width="3840" displayTitle="4K (HEVC Main 10)" extendedDisplayTitle="4K (HEVC Main 10)"></Stream>

<Stream id="471183" streamType="2" selected="1" default="1" codec="eac3" index="1" channels="6" bitrate="768" language="English" languageCode="eng" audioChannelLayout="5.1(side)" samplingRate="48000" streamIdentifier="2" displayTitle="English (EAC3 5.1)" extendedDisplayTitle="English (EAC3 5.1)"></Stream>

HDR/HDR10 4K Blu-ray w/ DTS-HD MA (7.1) audio, TrueHD (7.1) + Atmos

These are ordered according to the XML sheet.

<Stream id="483655" streamType="1" codec="hevc" index="0" bitrate="64783" language="English" languageCode="eng" bitDepth="10" chromaSubsampling="4:2:0" codedHeight="2160" codedWidth="3840" colorPrimaries="bt2020" colorRange="tv" colorSpace="bt2020nc" colorTrc="smpte2084" frameRate="23.976" height="2160" level="153" profile="main 10" refFrames="1" width="3840" displayTitle="4K (HEVC Main 10 HDR)"></Stream>

<Stream id="483656" streamType="2" selected="1" default="1" codec="truehd" index="1" channels="8" language="English" languageCode="eng" audioChannelLayout="7.1" bitDepth="24" samplingRate="48000" displayTitle="English (TRUEHD 7.1)"></Stream>

<Stream id="483657" streamType="2" codec="dca" index="2" channels="8" bitrate="1536" language="English" languageCode="eng" audioChannelLayout="7.1" bitDepth="24" profile="ma" samplingRate="48000" displayTitle="English (DTS-HD MA 7.1)"></Stream>

1080p Blu-ray with TrueHD (5.1)

<Stream id="475191" streamType="1" default="1" codec="h264" index="0" bitrate="31695" language="English" languageCode="eng" bitDepth="8" chromaLocation="left" chromaSubsampling="4:2:0" codedHeight="1088" codedWidth="1920" frameRate="23.976" hasScalingMatrix="0" height="1080" level="41" profile="high" refFrames="4" scanType="progressive" title="MPEG-4 AVC Video / 30733 kbps / 1080p / 23.976 fps / 16:9 / High Profile 4.1" width="1920" displayTitle="1080p (H.264)" extendedDisplayTitle="MPEG-4 AVC Video / 30733 kbps / 1080p / 23.976 fps / 16:9 / High Profile 4.1"></Stream>

<Stream id="475192" streamType="2" selected="1" default="1" codec="truehd" index="1" channels="6" language="English" languageCode="eng" audioChannelLayout="5.1(side)" bitDepth="24" samplingRate="48000" title="Dolby TrueHD Audio / 5.1 / 48 kHz / 1221 kbps / 16-bit" displayTitle="English (TRUEHD 5.1)" extendedDisplayTitle="Dolby TrueHD Audio / 5.1 / 48 kHz / 1221 kbps / 16-bit (English)"></Stream>

4K HLG

<Stream id="473044" streamType="1" default="1" codec="hevc" index="0" bitrate="18910" bitDepth="10" chromaSubsampling="4:2:0" codedHeight="2160" codedWidth="3840" colorPrimaries="bt2020" colorRange="tv" colorSpace="bt2020nc" colorTrc="arib-std-b67" frameRate="25.000" height="2160" level="153" profile="main 10" refFrames="1" width="3840" displayTitle="4K (HEVC Main 10)" extendedDisplayTitle="4K (HEVC Main 10)"></Stream>

@agneevX
Copy link
Contributor Author

agneevX commented Apr 10, 2021

I see that Trakt allows Atmos metadata for TrueHD or DDP+...

However, if you look at the XML data for either of those above, you'll notice that there's no mention of Atmos or Dynamic objects, so I guess you have to default to uploading metadata to the non Atmos version.

@glensc
Copy link
Collaborator

glensc commented Apr 10, 2021

@agneevX is there info on how you obtained those XML's? for me and for posterity.

I grepped through mine, they all were channels=2, which is weird.

@agneevX
Copy link
Contributor Author

agneevX commented Apr 10, 2021

Oh! Overflow menu → Get Info → View XML in bottom-left corner of the modal

@glensc
Copy link
Collaborator

glensc commented Apr 10, 2021

@agneevX this is very confusing to me, can you put up a table or logic on how to map these together for trakt?

for audio it seems simple, take audioChannelLayout from media.parts.audiostream:

but video, it has tons of attributes:

this area is very foreign here, I'm just trying to map available data, so help is appreachiated.

for example are uhd_4k (what trakt wants), 4K HLG (what you showed), 4K (HEVC Main 10) (what plex has in the stream field) the same thing or not, I have no idea!

I've added inspect command, to help printing the data (in #214):

$ ./plex_trakt_sync.sh inspect /library/metadata/9725
Audio: 'stereo', 'English (AAC Stereo)'
Video: h264

@glensc
Copy link
Collaborator

glensc commented Apr 10, 2021

I've now added a test case, so could mock the objects and see if the expected result is built:

$ ./test_collection_metadata.py
test_collection_metadata.py  [100%]
== 1 passed in 0.20s ===================

@agneevX
Copy link
Contributor Author

agneevX commented Apr 10, 2021

for example are uhd_4k (what trakt wants), 4K HLG (what you showed), 4K (HEVC Main 10) (what plex has in the stream field) the same thing or not, I have no idea!

Ok, so these are different.

uhd_4k is just 2160p 4K video, you have to determine the presence of HDR separately.

HLG is a HDR format, more on that below.

The other one is the text metadata label, it should be ignored.

This is the logic I'd say to determine HDR format:

Dolby Vision check - if media.VideoStream.DOVIPresent="1" is true, HDR format is Dolby Vision,

else check for HLG - if media.VideoStream.colorTrc is arib-std-b67 HDR format is HLG

else check for HDR/HDR10 - if media.VideoStream.colorTrc is smpte2084 HDR format is HDR10

else HDR is not present.

(I am not sure about HDR10Plus, because I don't have any such files.)

@glensc
Copy link
Collaborator

glensc commented Jun 19, 2021

Since there's no interest from anyone to write code for this, I'm going to merge existing PR as it is:

@agneevX
Copy link
Contributor Author

agneevX commented Jun 19, 2021

Maybe add a help-wanted tag??

@glensc glensc added the help wanted Extra attention is needed label Jun 20, 2021
@glensc
Copy link
Collaborator

glensc commented Jun 20, 2021

added label. would you update readme to add a section so people actually find such issues?

@mcdallas
Copy link
Contributor

mcdallas commented Jul 3, 2021

hey @glensc the Plex-Trakt-Scrobbler plugin supports this functionality nicely. I checked the source code and found the mapping logic here

@glensc
Copy link
Collaborator

glensc commented Jul 8, 2021

Added doc how to share xml:

glensc added a commit to glensc/PlexTraktSync that referenced this issue Jul 8, 2021
@glensc glensc reopened this Aug 1, 2021
@glensc
Copy link
Collaborator

glensc commented Aug 1, 2021

re-opening, as the current code submits typical 720p movies as 576p:

the thread there discusses a possible solution.

Repository owner locked as resolved and limited conversation to collaborators Jan 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed
Projects
None yet
4 participants