Forum Discussion

youssefsherif's avatar
youssefsherif
Streaming Star
3 years ago

task node data loading from a json file

how can i load data from a json file through a task node instead of loading it in mainscene brs?

3 Replies

    • youssefsherif's avatar
      youssefsherif
      Streaming Star
      sub createRowItems(json as Object, listContent as Object)
        for each postDataContainer in json.data.children
          postData = postDataContainer.data
          post = {
            title: postData.title,
            selfText: postData.selfText,
            thumbnail: postData.thumbnail,
            isVideo: postData.is_video,
            url: postData.url,
            isSelf: postData.isSelf
          }
      
          if post.isVideo then
            itemContent = listContent.createChild("ContentNode")
            itemContent.update({ isSelf: post.isSelf }, true)
            itemContent.title = post.title
            itemContent.description = post.selfText
            itemContent.url = post.url
      
            if post.thumbnail <> "self" and post.thumbnail <> "default" and post.thumbnail <> "image" then
              itemContent.SDPosterUrl = post.thumbnail
            end if
      
            if post.isVideo then
              itemContent.url = post.url + "/DASHPlaylist.mpd"
              itemContent.streamformat = "dash"
            end if
      
            if postData.media <> invalid and postData.media.type = "youtube.com" then
              itemContent.videoUrl = postData.url
              itemContent.streamFormat = "youtube"
            end if
      
            extension = right(postData.url, 4)
            if extension = ".png" or extension = ".jpg" then
              itemContent.SDPosterUrl = postData.url
            end if
      
            itemContent.update({
              isRedditVideo: (postData.media <> invalid and postData.media.reddit_video <> invalid)
            }, true)
          end if
        end for
      end sub

      i believe ill be using this part