Aide pour parse un fichier XML

Bonjour,

Je suis désolé pour cette demande qui est surement faite régulièrement mais je n’arrive pas à comprendre comment récupérer une valeur pour ce fichier XML qui est un peu confus (API Plex):

J’essaye de récupérer des valeurs (String) comme « LibrarySectionTitle » dans Video par exemple, Et « device » dans Player
Mais Jeedom me renvoie rien :frowning: Pas d’erreur, juste rien…

Merci d’avance


> Citation
    <?xml version="1.0" encoding="UTF-8"?>
    <MediaContainer size="1">
    <Video addedAt="1598620136" art="/library/metadata/25375/art/1598620204" contentRating="TV-PG" duration="1668251" grandparentArt="/library/metadata/25375/art/1598620204" grandparentGuid="com.plexapp.agents.thetvdb://282562?lang=en" grandparentKey="/library/metadata/25375" grandparentRatingKey="25375" grandparentTheme="/library/metadata/25375/theme/1598620204" grandparentThumb="/library/metadata/25375/thumb/1598620204" grandparentTitle="XXX" guid="com.plexapp.agents.thetvdb://282562/1/11?lang=en" index="11" key="/library/metadata/25402" lastViewedAt="1598795960" librarySectionID="2" librarySectionKey="/library/sections/2" librarySectionTitle="TV Shows" originallyAvailableAt="2015-05-08" parentGuid="com.plexapp.agents.thetvdb://282562/1?lang=en" parentIndex="1" parentKey="/library/metadata/25391" parentRatingKey="25391" parentThumb="/library/metadata/25391/thumb/1598620203" parentTitle="Season 1" rating="8.3" ratingKey="25402" sessionKey="33" summary="" thumb="/library/metadata/25402/thumb/1598620199" title="The" titleSort="XX" type="episode" updatedAt="1598620199" viewOffset="459149" year="2015">
    <Media aspectRatio="1.85" audioChannels="6" audioCodec="ac3" bitrate="3097" container="mkv" duration="1668251" height="676" id="29720" videoCodec="h264" videoFrameRate="24p" videoProfile="high" videoResolution="720" width="1280" selected="1">
    <Part container="mkv" duration="1668251" file=".mkv" id="55512" key="/library/parts/55512/1598606982/file.mkv" size="646112985" videoProfile="high" decision="directplay" selected="1">
    <Stream bitDepth="8" bitrate="2457" chromaLocation="left" chromaSubsampling="4:2:0" codec="h264" codedHeight="688" codedWidth="1280" colorRange="tv" colorSpace="bt709" default="1" displayTitle="720p (H.264)" extendedDisplayTitle="720p (H.264)" frameRate="23.976" hasScalingMatrix="0" height="676" id="148362" index="0" language="English" languageCode="eng" level="41" profile="high" refFrames="5" scanType="progressive" streamType="1" width="1280" location="direct" />
    <Stream audioChannelLayout="5.1(side)" bitrate="639" channels="6" codec="ac3" default="1" displayTitle="Unknown (AC3 5.1)" extendedDisplayTitle="Unknown (AC3 5.1)" id="148363" index="1" samplingRate="48000" selected="1" streamType="2" location="direct" />
    </Part>
    </Media>
    <User id="1" thumb="https://plex.tv/users" title="" />
    <Player address="192.168.0.24" device="SHIELD Android TV" machineIdentifier="b068759242301048-com-plexapp-android" model="darcy" platform="Android" platformVersion="9" product="Plex for Android (TV)" profile="Android" remotePublicAddress="82.67.218.120" state="playing" title="SHIELD Android TV" vendor="NVIDIA" version="8.5.1.19778" local="1" relayed="0" secure="1" userID="1" />
    <Session id="b068759242301048-com-plexapp-android" bandwidth="3371" location="lan" />
    </Video>
    </MediaContainer>

Voilà un sujet datant d’hier avec ce qui me semble être la même question (et la réponse):
https://community.jeedom.com/t/recup-valeur-dans-fichier-xml-puis-ajout-dans-virtuel/35935/4

Malheureusement je n’arrive pas à comprendre quelle requete je dois mettre car les balises XML ne sont pas aussi clairement définies que dans les exemples de fichier XML qu’on voit.

et ça donne quoi si tu mets seulement « MediaContainer » (sans guillemets) dans ta requête XML ?

si ça t’affiche le XML, à partir de la balise video, alors tu n’auras plus qu’à scripter (via une seconde cmd) pour récup le contenu de librarySectionTitle=""

Malheuresement aucun résultat :frowning: Ou alors -fait probable- je loupe quelque chose d’évident… Capture d’écran pour aider à voir si j’ai mal compris quelque chose.
L’URL est correcte et retourne les données que j’ai mis dans mon premier message

1 « J'aime »

pourquoi as tu coché SSL alors que tu fais un appel en http ?

Miss click je pense (je suis sur un portable). Je viens de l’enlever et de tester, malheureusement toujours aucun retour :frowning:

1 « J'aime »

quand bien même tu as un token, tu n’aurais pas un user/pwd à spécifier pour accéder à fichier ?

nope :frowning: L’url fonctionne sur chrome sans plus d’information que celle mise dans le plugin. Désolé l’URL a mon token perso donc je peux pas la partager :frowning:

file moi le lien sans ton token, sans ton ip pour voir, je viens de me monter un plex vite fait
(histoire de pas chercher la syntaxe pour récup le xml)

1 « J'aime »

Merci pour ton aide!
http://XXXXXXX/status/sessions?X-Plex-Token=YYYYYYYYYYYYYYYYYY

Tu trouveras ton token en allant sur un épisode / film, clique sur « More », ensuite « Get Info ». Et dans la fenetre qui s’ouvrira tu as « VIew XML ».
Le token se cache dedans !

Même résultat que toi :frowning:

1 « J'aime »

Salut,

Il faudra que je vérifies à mon retour mais avant que mon disque dur remplit de films me lâche je récupérais les données xml de plex en me basant sur ce post de l’ancien forum :
https://forum.jeedom.com/viewtopic.php?t=37465

De mémoire je l’avais bien adapté au final mais je n’utilise plus depuis un moment car je n’ai pas remonté de nouveau serveur plex

1 « J'aime »

Désolé @Salvialf, je n’avais pas activé les notifications et je n’avais pas vu ta réponse !

Alors pour commencer, merci bcp pour ton aide et pour ton lien. J’ai un peu (bcp :wink: ) galéré à implémenter votre conversation mais j’ai finalement réussi !

Par contre, je rencontre un souci lorsque plus d’un flux est actif en même temps sur mon Plex; la transformation en JSON ne fonctionne plus (le contenu du fichier devient « false » c’est tout).
De ce que je peux voir, tu as pourtant prévu une loop si il y’avait plus d’un " < Video > " mais ça ne semble pas fonctionner chez moi :frowning:

Juste quand j’ai essayé de trouver d’où pouvait provenir l’erreur, j’ai créé un document avec ce contenu:
$XML_Resultat = $Processus->transformToXML($DocDOM_XML);
et il m’indique une erreur:
This page contains the following errors:
error on line 13 at column 9: Extra content at the end of the document
Below is a rendering of the page up to the first error.
2 TV Shows Grouchy Goat () 0:27:1 027 playing XXXXX lan Android SHIELD Android TV

Je suppose que ça vient du fait qu’il arrive donc pas à faire la deuxième boucle, mais aucune idée du pourquoi :frowning: (Le code fonctionne bien quand j’utilise un outil online)

Je mets le XML de Plex si une âme charitable voulait m’aider à comprendre !

Merci d’avance !

Résumé
<MediaContainer size="2">
<Video addedAt="1620365179" art="/library/metadata/26776/art/1620365181" contentRating="TV-MA" duration="1621344" grandparentArt="/library/metadata/26776/art/1620365181" grandparentGuid="plex://show/5d9c0922170e24001f2af500" grandparentKey="/library/metadata/26776" grandparentRatingKey="26776" grandparentTheme="/library/metadata/26776/theme/1620365181" grandparentThumb="/library/metadata/26776/thumb/1620365181" grandparentTitle="Mythic Quest" guid="plex://episode/607989c766e6f40035f67997" index="2" key="/library/metadata/27013" lastViewedAt="1620681111" librarySectionID="2" librarySectionKey="/library/sections/2" librarySectionTitle="TV Shows" originallyAvailableAt="2021-05-07" parentGuid="plex://season/60341033f4eb20002c1db2af" parentIndex="2" parentKey="/library/metadata/27011" parentRatingKey="27011" parentTitle="Season 2" ratingKey="27013" sessionKey="75" summary="Brad wants to launch a mobile game. Poppy is pulled away from working on the expansion with Ian to speak at a luncheon for women in gaming." thumb="/library/metadata/27013/thumb/1620521643" title="Grouchy Goat" type="episode" updatedAt="1620521643" viewCount="1" viewOffset="1285516">
<Media aspectRatio="1.85" audioChannels="6" audioCodec="eac3" bitrate="3566" container="mkv" duration="1621344" height="678" id="32014" videoCodec="h264" videoFrameRate="24p" videoProfile="high" videoResolution="720" width="1356" selected="1">
<Part container="mkv" duration="1621344" file="/tv/Mythic Quest/Season 02/Mythic.quest.Ravens.Banquet.S02E02.720p.WEB.DL-GGEZ.mkv" id="72372" key="/library/parts/72372/1620365007/file.mkv" size="723931831" videoProfile="high" decision="directplay" selected="1">
<Stream bitDepth="8" bitrate="2793" chromaLocation="topleft" chromaSubsampling="4:2:0" codec="h264" codedHeight="688" codedWidth="1360" colorPrimaries="bt709" colorRange="tv" colorSpace="bt709" colorTrc="bt709" default="1" displayTitle="720p (H.264)" extendedDisplayTitle="720p (H.264)" frameRate="23.976" hasScalingMatrix="0" height="678" id="206139" index="0" language="English" languageCode="eng" level="32" profile="high" refFrames="5" scanType="progressive" streamType="1" width="1356" location="direct"/>
<Stream audioChannelLayout="5.1(side)" bitrate="768" channels="6" codec="eac3" default="1" displayTitle="English (EAC3 5.1)" extendedDisplayTitle="English (EAC3 5.1)" id="206140" index="1" language="English" languageCode="eng" samplingRate="48000" selected="1" streamType="2" location="direct"/>
</Part>
</Media>
<Director filter="director=35338" id="35338" tag="Pete Chatmon"/>
<Writer filter="writer=34469" id="34469" tag="Rob McElhenney"/>
<Writer filter="writer=14668" id="14668" tag="Megan Ganz"/>
<Writer filter="writer=34470" id="34470" tag="David Hornsby"/>
<Role filter="actor=38252" id="38252" role="Phil" tag="Derek Waters" thumb="https://metadata-static.plex.tv/people/5d77683454f42c001f8c4384.jpg"/>
<Role filter="actor=38253" id="38253" role="SnickrSnack" tag="Cooper J. Friedman" thumb="https://metadata-static.plex.tv/d/people/de9c543197ccc03fdc2a91a8c8df6c44.jpg"/>
<Role filter="actor=38254" id="38254" role="Tracy Fullerton" tag="Tracy Fullerton"/>
<Role filter="actor=38179" id="38179" role="Kevin" tag="Chris Naoki Lee" thumb="https://metadata-static.plex.tv/people/5f85bf396335860040220d73.jpg"/>
<User id="1" thumb="XXXXXXX" title="XXXXX"/>
<Player address="XXXXXX" device="SHIELD Android TV" machineIdentifier="XXXXXXX" model="darcy" platform="Android" platformVersion="9" product="Plex for Android (TV)" profile="Android" remotePublicAddress="XXXXXX" state="playing" title="SHIELD Android TV" vendor="NVIDIA" version="8.16.2.24953" local="1" relayed="0" secure="1" userID="1"/>
<Session id="XXXXXXXX" bandwidth="3872" location="lan"/>
</Video>
<Video addedAt="1620034194" art="/library/metadata/26989/art/1620034195" contentRating="PG" duration="6842656" guid="plex://movie/5d776da351dd69001fe44300" key="/library/metadata/26989" librarySectionID="1" librarySectionKey="/library/sections/1" librarySectionTitle="Movies" originallyAvailableAt="2021-04-30" primaryExtraKey="/library/metadata/26990" rating="9.5" ratingImage="rottentomatoes://image.rating.ripe" ratingKey="26989" sessionKey="73" studio="Lord Miller Productions" summary="A quirky, dysfunctional family's road trip is upended when they find themselves in the middle of the robot apocalypse and suddenly become humanity's unlikeliest last hope." tagline="Saving the world can be a trip." thumb="/library/metadata/26989/thumb/1620034195" title="The Mitchells vs. the Machines" titleSort="Mitchells vs. the Machines" type="movie" updatedAt="1620034195" viewOffset="1480470" year="2021">
<Media aspectRatio="1.78" audioChannels="6" audioCodec="eac3" bitrate="7562" container="mkv" duration="6842656" height="1080" id="31979" videoCodec="h264" videoFrameRate="24p" videoProfile="high" videoResolution="1080" width="1920" selected="1">
<Part container="mkv" duration="6842656" file="/movies/The.Mitchells.vs.The.Machines.2021.1080p.WEB.h264-RUMOUR.mkv" id="72337" key="/library/parts/72337/1620034114/file.mkv" size="6471349296" videoProfile="high" decision="directplay" selected="1">
<Stream bitDepth="8" bitrate="6791" chromaLocation="left" chromaSubsampling="4:2:0" codec="h264" codedHeight="1088" codedWidth="1920" default="1" displayTitle="1080p (H.264)" extendedDisplayTitle="1080p (H.264)" frameRate="23.976" hasScalingMatrix="0" height="1080" id="205879" index="0" language="English" languageCode="eng" level="40" profile="high" refFrames="4" scanType="progressive" streamType="1" width="1920" location="direct"/>
<Stream audioChannelLayout="5.1(side)" bitrate="768" channels="6" codec="eac3" default="1" displayTitle="English (EAC3 5.1)" extendedDisplayTitle="English (EAC3 5.1)" id="205880" index="1" language="English" languageCode="eng" samplingRate="48000" selected="1" streamType="2" location="direct"/>
</Part>
</Media>
<Genre count="36" filter="genre=1662" id="1662" tag="Animation"/>
<Genre count="100" filter="genre=77" id="77" tag="Comedy"/>
<Genre count="66" filter="genre=565" id="565" tag="Family"/>
<Genre count="15" filter="genre=25685" id="25685" tag="Science Fiction"/>
<Genre count="27" filter="genre=32677" id="32677" tag="Action/Adventure"/>
<Director filter="director=35095" id="35095" tag="Jeff Rowe"/>
<Director filter="director=35096" id="35096" tag="Michael Rianda"/>
<Writer filter="writer=35097" id="35097" tag="Jeff Rowe"/>
<Writer filter="writer=35098" id="35098" tag="Michael Rianda"/>
<Producer filter="producer=35099" id="35099" tag="Kurt Albrecht"/>
<Producer filter="producer=35100" id="35100" tag="Phil Lord"/>
<Producer filter="producer=35101" id="35101" tag="Christopher Miller"/>
<Country count="32" filter="country=26375" id="26375" tag="United States of America"/>
<Role filter="actor=11289" id="11289" role="Katie Mitchell / Dog Cop (voice)" tag="Abbi Jacobson" thumb="https://metadata-static.plex.tv/people/5d776ae9594b2b001e6c9689.jpg"/>
<Role count="4" filter="actor=15" id="15" role="Rick Mitchell (voice)" tag="Danny McBride" thumb="http://image.tmdb.org/t/p/original/44DW4hNukuxNhGwyMScNNKhwflN.jpg"/>
<Role count="2" filter="actor=9111" id="9111" role="Linda Mitchell (voice)" tag="Maya Rudolph" thumb="https://metadata-static.plex.tv/a/people/aa4c27f020179c4aa1caa74b784df3a5.jpg"/>
<Role filter="actor=35079" id="35079" role="Aaron Mitchell / Furbies / Talking Dog / Wifi Enthusiast (voice)" tag="Michael Rianda"/>
<Role count="2" filter="actor=25355" id="25355" role="Mark Bowman (voice)" tag="Eric André" thumb="https://metadata-static.plex.tv/people/5d77684b103a2d001f56c411.jpg"/>
<Role count="2" filter="actor=7252" id="7252" role="PAL (voice)" tag="Olivia Colman" thumb="https://metadata-static.plex.tv/3/people/381793fe7936a120511d15dce114572b.jpg"/>
<Role filter="actor=35080" id="35080" role="Deborahbot 5000 (voice)" tag="Fred Armisen" thumb="https://metadata-static.plex.tv/people/5d77682b8a7581001f12c40e.jpg"/>
<Role count="2" filter="actor=3371" id="3371" role="Eric / Pal Max Robots (voice)" tag="Beck Bennett" thumb="http://image.tmdb.org/t/p/original/xbcVvJ1a7qUIdyYb4PJewFlNFu4.jpg"/>
<Role filter="actor=35081" id="35081" role="Hailey Posey (voice)" tag="Chrissy Teigen" thumb="https://metadata-static.plex.tv/people/5d776b7b7a53e9001e7274aa.jpg"/>
<Role count="2" filter="actor=2054" id="2054" role="Jim Posey (voice)" tag="John Legend" thumb="http://image.tmdb.org/t/p/original/y0p52grR5jLEEsbFDexsOd4zkJg.jpg"/>
<Role filter="actor=13832" id="13832" role="Abbey Posey (voice)" tag="Charlyne Yi" thumb="https://metadata-static.plex.tv/2/people/24cfa58a859fbdaf701e1f1fc0a68907.jpg"/>
<Role filter="actor=35082" id="35082" role="Pal Max Prime (voice)" tag="Blake Griffin" thumb="https://metadata-static.plex.tv/8/people/8d4662b439c9baee170eaceb95383c3a.jpg"/>
<Role filter="actor=35083" id="35083" role="Glaxxon 5000 (voice)" tag="Conan O'Brien" thumb="https://metadata-static.plex.tv/people/5d77683f6f4521001ea9dd52.jpg"/>
<Role filter="actor=35084" id="35084" role="Sarge / Melissa (Woman In Pod) (voice)" tag="Melissa Sturm"/>
<Role filter="actor=35085" id="35085" role="Hamburger Boy / Smart-Racket 5000-S Series (voice)" tag="Doug Nicholas"/>
<Role filter="actor=35086" id="35086" role="Baby Katie (voice)" tag="Ellen Wightman"/>
<Role filter="actor=35087" id="35087" role="Jade (voice)" tag="Sasheer Zamata" thumb="https://metadata-static.plex.tv/people/5d776af6594b2b001e6cacb6.jpg"/>
<Role filter="actor=35088" id="35088" role="Hanna (voice)" tag="Elle Mills"/>
<Role filter="actor=35089" id="35089" role="Dirk (voice)" tag="Alex Hirsch" thumb="https://metadata-static.plex.tv/3/people/300e7d23a0b9aefaf7678b038cf0c773.jpg"/>
<Role count="2" filter="actor=3387" id="3387" role="Noah (voice)" tag="Jay Pharoah" thumb="https://metadata-static.plex.tv/2/people/2844d10e2b2d385cd7867d3816d1ea6e.jpg"/>
<Role filter="actor=35090" id="35090" role="Catherine (Food Blogger) (voice)" tag="Natalie Canizares" thumb="https://metadata-static.plex.tv/f/people/f504b864e3fe0b2261e127ed23734ed8.jpg"/>
<Role filter="actor=35091" id="35091" role="Man Who Loves Fun (voice)" tag="Jeff Rowe"/>
<Role filter="actor=35092" id="35092" role="Sean (Unboxer) (voice)" tag="Zeno Robinson" thumb="https://metadata-static.plex.tv/2/people/2d461bb33fa7d8c219006c254081445a.jpg"/>
<Role count="5" filter="actor=20088" id="20088" role="Stagehand (voice)" tag="Grey DeLisle" thumb="https://metadata-static.plex.tv/a/people/ae77d3c48aed12e52a004ca2852e76ff.jpg"/>
<Role filter="actor=35093" id="35093" role="Water Fountain Man (voice)" tag="Will Allegra"/>
<Role filter="actor=35094" id="35094" role="Jill (Woman In Pod) (voice)" tag="Alison Rich" thumb="https://metadata-static.plex.tv/people/5d776ba4fb0d55001f56e46f.jpg"/>
<Role count="4" filter="actor=4510" id="4510" role="Young Katie (voice)" tag="Madeleine McGraw" thumb="https://metadata-static.plex.tv/people/5d776a12ad5437001f77113d.jpg"/>
<User id="20402637" thumb="YYYYYY" title="YYYYYY"/>
<Player address="YYYYYY" device="RaspberryPi" machineIdentifier="YYYYYYYYY" model="RaspberryPi" platform="Plex Home Theater" platformVersion="" product="Plex Home Theater" profile="Raspberry PI" remotePublicAddress="YYYYYYY" state="playing" title="RasPlex" vendor="" version="1.8.0.148-573b6d73" local="0" relayed="0" secure="1" userID="YYYYYY"/>
<Session id="YYYYYYYY" bandwidth="20354" location="wan"/>
</Video>
</MediaContainer>