how read json
Posted: Wednesday 04 March 2020 16:48
by OedzesG
Hallo,
i try to get Tautulli data to Domoticz but having some problems with reading.
Can someone tell me how i read this json call?
This is my script so far....
i try to get Tautulli data to Domoticz but having some problems with reading.
Can someone tell me how i read this json call?
- Spoiler: show
Code: Select all
{ "response": { "message": null, "data": { "sessions": [ { "rating": "8.0", "transcode_width": "", "labels": [ ], "stream_video_color_primaries": "bt709", "stream_bitrate": "4934", "bandwidth": "5181", "optimized_version": 0, "video_language": "", "parent_rating_key": "50", "rating_key": "62", "video_decision": "transcode", "transcode_hw_decoding": 1, "thumb": "/library/metadata/62/thumb/1583237929", "title": "Pilot", "video_codec_level": "40", "tagline": "", "last_viewed_at": "1583269297", "synced_version": 0, "transcode_audio_channels": "2", "user_rating": "", "platform": "Chrome", "collections": [ ], "location": "lan", "transcode_container": "mp4", "audio_channel_layout": "5.1(side)", "stream_duration": "4874976", "local": 1, "stream_video_ref_frames": "", "stream_video_width": "1920", "transcode_hw_encode_title": "Intel (VA API)", "stream_container_decision": "transcode", "audience_rating": "", "full_title": "Suits - Pilot", "ip_address": "192.168.1.14", "transcode_speed": "0.0", "stream_subtitle_language": "Nederlands", "channel_stream": 0, "video_bitrate": "3119", "is_allow_sync": 1, "stream_video_bitrate": "4678", "summary": "Harvey geeft Mike zijn eerste zaak, een pro-bono zaak waarbij een CEO wordt verdacht van seksuele intimidatie. Harvey moet zijn beste spel uit de kast trekken, om Mike gemotiveerd te houden.", "stream_video_color_range": "", "stream_audio_decision": "transcode", "aspect_ratio": "1.78", "audio_bitrate_mode": "", "transcode_hw_decode_title": "Intel (VA API)", "machine_id": "e8z5wabv80hjz27c5jylzghi", "deleted_user": 0, "library_name": "Series", "art": "/library/metadata/62/art/1583237929", "stream_video_resolution": "1080", "video_profile": "high", "video_color_space": "bt709", "sort_title": "", "stream_video_codec_level": "", "stream_video_height": "1080", "year": "2011", "duration": "4874976", "video_scan_type": "progressive", "progress_percent": "5", "video_language_code": "", "transcode_key": "/transcode/sessions/lofnrw2wr5qaz6emp72kbslb", "transcode_throttled": 1, "container": "mkv", "stream_audio_bitrate": "256", "user": "Gerard Oedzes", "selected": 1, "subtitle_location": "embedded", "transcode_hw_requested": 1, "video_height": "1080", "state": "paused", "is_restricted": 0, "email": "[email protected]", "stream_container": "mp4", "stream_video_dynamic_range": "SDR", "video_bit_depth": "8", "stream_audio_sample_rate": "", "grandparent_title": "Suits", "studio": "USA Network", "transcode_decision": "transcode", "video_width": "1920", "bitrate": "3503", "stream_audio_channel_layout": "Stereo", "originally_available_at": "2011-06-23", "video_frame_rate": "23.976", "synced_version_profile": "", "friendly_name": "Gerard Oedzes", "audio_profile": "", "video_chroma_subsampling": "4:2:0", "platform_name": "chrome", "stream_video_language": "", "keep_history": 1, "stream_subtitle_container": "", "stream_audio_codec": "aac", "stream_video_full_resolution": "1080p", "video_codec": "h264", "grandparent_thumb": "/library/metadata/49/thumb/1583237992", "audio_bitrate": "384", "transcode_hw_decode": "vaapi", "secure": 1, "user_thumb": "https://plex.tv/users/9f5caff9a3cd56ab/avatar?c=1578427885", "video_color_primaries": "bt709", "height": "1080", "stream_subtitle_decision": "burn", "audio_codec": "ac3", "parent_title": "Season 1", "guid": "com.plexapp.agents.thetvdb://247808/1/1?lang=nl", "stream_video_scan_type": "", "audio_language_code": "eng", "transcode_video_codec": "h264", "transcode_audio_codec": "aac", "stream_video_decision": "transcode", "stream_video_color_trc": "bt709", "user_id": 20020070, "transcode_height": "", "transcode_hw_full_pipeline": 0, "throttled": "1", "grandparent_guid": "com.plexapp.agents.thetvdb://247808?lang=nl", "live": 0, "width": "1920", "quality_profile": "Original", "stream_subtitle_forced": 0, "media_type": "episode", "video_resolution": "1080", "stream_subtitle_location": "segments-video", "do_notify": 1, "video_ref_frames": "4", "stream_subtitle_language_code": "dut", "product_version": "4.22.2", "stream_audio_language_code": "eng", "optimized_version_profile": "", "rating_image": "", "is_home_user": 0, "is_admin": 1, "ip_address_public": "213.93.65.245", "allow_guest": 0, "video_color_range": "tv", "audio_sample_rate": "48000", "stream_audio_channel_layout_": "", "media_index": "1", "stream_video_framerate": "24p", "transcode_hw_encode": "vaapi", "grandparent_rating_key": "49", "original_title": "", "added_at": "1583236273", "banner": "/library/metadata/49/banner/1583237992", "bif_thumb": "", "parent_media_index": "1", "live_uuid": "", "audio_language": "English", "stream_audio_bitrate_mode": "cbr", "username": "Gerard Oedzes", "video_color_trc": "bt709", "subtitle_decision": "burn", "parent_guid": "com.plexapp.agents.thetvdb://247808/1?lang=nl", "video_dynamic_range": "SDR", "children_count": "", "updated_at": "1583237929", "video_full_resolution": "1080p", "player": "Chrome", "audio_channels": "6", "subtitle_format": "", "file": "/home/gerard/synology_share/ds218/multimedia/serie/Suits/season 1/suits S01E01 Pilot.mkv", "file_size": "2134833392", "session_key": "12", "subtitles": 1, "id": "341", "subtitle_container": "", "optimized_version_title": "", "genres": [ "Comedy", "Drama" ], "stream_audio_channels": "2", "stream_video_language_code": "", "relayed": 0, "indexes": 0, "platform_version": "80.0", "stream_audio_language": "English", "writers": [ "Aaron Korsh" ], "actors": [ "Aloma Wright", "Gabriel Macht", "Sarah Rafferty", "Wendell Pierce", "Patrick J. Adams", "Abigail Spencer", "Dulé Hill", "Gina Torres", "Amanda Schull", "D.B. Woodside", "Meghan Markle", "Rachael Harris", "Katherine Heigl", "Rick Hoffman" ], "stream_subtitle_format": "", "audio_decision": "transcode", "subtitle_forced": 0, "profile": "Web", "product": "Plex Web", "view_offset": "238000", "type": "3", "audience_rating_image": "", "section_id": "3", "stream_subtitle_codec": "", "stream_video_color_space": "", "subtitle_codec": "ass", "stream_video_codec": "h264", "device": "Windows", "stream_video_bit_depth": "", "video_framerate": "24p", "transcode_hw_encoding": 1, "transcode_protocol": "dash", "shared_libraries": [ "1", "2", "3" ], "stream_aspect_ratio": "", "content_rating": "TV-14", "session_id": "ppgvxw0s9rg4bq40ktm29gei", "directors": [ "Kevin Bray" ], "parent_thumb": "/library/metadata/50/thumb/1583237889", "subtitle_language_code": "dut", "transcode_progress": 8, "subtitle_language": "Nederlands", "stream_video_chroma_subsampling": "" } ], "stream_count": "1", "total_bandwidth": 5181, "stream_count_transcode": 1, "wan_bandwidth": 0, "stream_count_direct_play": 0, "lan_bandwidth": 5181, "stream_count_direct_stream": 0 }, "result": "success" } }
This is my script so far....
Code: Select all
local scriptVersion = ' testing '
local scriptVar = ' plex woonkamer ' .. scriptVersion
local tautulli_ip = 'xxx'
local tautulli_api = 'xxx'
return
{
on =
{
customEvents = { 'plex',},
},
httpResponses = { scriptVar,
},
logging = { level = domoticz.LOG_DEBUG,
marker = scriptVar,
},
execute = function(dz, item)
dz.openURL ({
url = 'http://' .. tautulli_ip .. '/api/v2?apikey=' .. tautulli_api .. '&cmd=get_activity',
method = 'GET',
callback = scriptVar
})
end
}