/* method:	setHuluResult
usage:	setHuluResult(mixed videoID);
params:	videoID = video ID for hulu content

This method reads the video data from the sitemap into the huluResult property.

returns: void
552213
public function setHuluResult($videoID)
		{
			global $urlData;

			$fileName = $this->getSearchFile($videoID);

			$doc = new \DOMDocument;
			$doc->preserveWhiteSpace = false;

			$file = realpath($this->dataFolder . '/' . $fileName);
			$doc->load($file);

			$xpath = new \DOMXpath($doc);

			$query = "/*/*/*[text() = 'http://www.hulu.com/watch/".$videoID."']/..";
			$results = $xpath->query($query);

			$node = $results->item(0);

			$this->processNode($node);

			$this->huluResult['loc'] 					= $urlData['url']['loc'];
			$this->huluResult['thumbnail_loc'] 			= $urlData['video:video']['video:thumbnail_loc'];
			$this->huluResult['title'] 					= $urlData['video:video']['video:title'];
			$this->huluResult['description'] 			= $urlData['video:video']['video:description'];
			$this->huluResult['family_friendly'] 		= $urlData['video:video']['video:family_friendly'];
			$this->huluResult['duration'] 				= $urlData['video:video']['video:duration'];
			$this->huluResult['rating'] 				= $urlData['video:video']['video:rating'];
			$this->huluResult['publication_date'] 		= $urlData['video:video']['video:publication_date'];
			$this->huluResult['season_number'] 			= $urlData['video:video']['video:season_number'];
			$this->huluResult['video_type'] 			= $urlData['video:video']['video:video_type'];
			$this->huluResult['air_date'] 				= $urlData['video:video']['video:air_date'];
			$this->huluResult['added_date'] 			= $urlData['video:video']['video:added_date'];
			$this->huluResult['company'] 				= $urlData['video:video']['video:company'];
			$this->huluResult['requires_subscription'] 	= $urlData['video:video']['video:requires_subscription'];
			$this->huluResult['content_id'] 			= $urlData['video:video']['hulu-video:content_id'];
			$this->huluResult['show_id'] 				= $urlData['video:video']['hulu-video:show_id'];
			$this->huluResult['seriesDescription'] 		= $urlData['video:video']['hulu:seriesDescription'];
			$this->huluResult['mediaType'] 				= $urlData['video:video']['hulu:mediaType'];
			$this->huluResult['channel'] 				= $urlData['video:video']['hulu:channel'];
			$this->huluResult['hulu']['season_number'] 	= $urlData['video:video']['hulu-video:season_number'];
			$this->huluResult['hulu']['air_date'] 		= $urlData['video:video']['hulu-video:air_date'];
			$this->huluResult['hulu']['company'] 		= $urlData['video:video']['hulu-video:company'];
			$this->huluResult['show']['show_title'] 	= $urlData['video:tvshow']['video:show_title'];
			$this->huluResult['show']['video_type'] 	= $urlData['video:tvshow']['video:video_type'];
			$this->huluResult['show']['episode_title'] 	= $urlData['video:tvshow']['video:episode_title'];
			$this->huluResult['show']['premier_date'] 	= $urlData['video:tvshow']['video:premier_date'];
		}
383207
private boolean sendCheckVideoCM() {
        OOBControlMessage oobCtrlMsg = new OOBControlMessage();
        oobCtrlMsg.setTarget(IStreamTypeAwareProvider.KEY);
        oobCtrlMsg.setServiceName("hasVideo");
        msgInReference.get().sendOOBControlMessage(this, oobCtrlMsg);
        if (oobCtrlMsg.getResult() instanceof Boolean) {
            return (Boolean) oobCtrlMsg.getResult();
        } else {
            return false;
        }
    }
883938
def videos_for(items, key, options)
      items.body['items'].map{|item| item['id'] = item[key]['videoId']}

      if options[:parts] == %i(id)
        items
      else
        options[:ids] = items.body['items'].map{|item| item['id']}
        options[:offset] = nil
        get('/youtube/v3/videos', resource_params(options)).tap do |response|
          response.body['nextPageToken'] = items.body['nextPageToken']
        end
      end
    end
961775
protected void writeVideo(VideoEntry videoEntry) throws IOException {

        writer.append("video::").append(videoEntry.getLink()).append("[]").append(NEW_LINE).append(NEW_LINE);

    }
473376
public function openidVideo($media_id = '', $openids = [], $title = '', $description = '')
    {
        $queryStr                      = [];
        $queryStr['touser']            = $openids;
        $queryStr['video']['media_id'] = $media_id;

        if (!empty($title)) {
            $queryStr['video']['title'] = $title;
        }

        if (!empty($description)) {
            $queryStr['video']['description'] = $description;
        }

        $queryStr['msgtype'] = 'video';

        $this->module = 'message';

        $res = $this->_post('mass/send', $queryStr);

        return $res;
    }
21924
function getVideoStatistics(auth, youtube, items, count, callback) {

  // Convert the video ID:s of the provided videos to the appropriate format
  var IDs = "";
  if (Array.isArray(items)) {
    for (var i = 0; i < items.length; i++) {
      if (i != 0) {
        IDs += ", "
      }
      IDs += items[i].id.videoId;
    }
  }

  youtube.videos.list( // Call the Youtube API
  {
    auth: auth,
    part: "statistics",
    id: IDs,
    maxResults: count //integer 0-50, default 5
  },
  function(err, res) {
    if (err) {
      console.log("The API returned an error: " + err);
    } else {
      var formatedVideos = formatVideosJson(items, res.data.items); // Format the recieved JSON object filled with videos
      callback(formatedVideos);
    }
  });
}
884946
@WorkerThread
    public ArrayList<AlbumFolder> getAllVideo() {
        Map<String, AlbumFolder> albumFolderMap = new HashMap<>();
        AlbumFolder allFileFolder = new AlbumFolder();
        allFileFolder.setChecked(true);
        allFileFolder.setName(mContext.getString(R.string.album_all_videos));

        scanVideoFile(albumFolderMap, allFileFolder);

        ArrayList<AlbumFolder> albumFolders = new ArrayList<>();
        Collections.sort(allFileFolder.getAlbumFiles());
        albumFolders.add(allFileFolder);

        for (Map.Entry<String, AlbumFolder> folderEntry : albumFolderMap.entrySet()) {
            AlbumFolder albumFolder = folderEntry.getValue();
            Collections.sort(albumFolder.getAlbumFiles());
            albumFolders.add(albumFolder);
        }
        return albumFolders;
    }
986256
function() {

		// Create Dom element
		this._el.content_item   = TL.Dom.create("div", "tl-media-item tl-media-map tl-media-shadow", this._el.content);

		// Get Media ID
		this.media_id = this.data.url;

		// API Call
		this.mapframe = TL.Dom.create("iframe", "", this._el.content_item);
		window.stash = this;
		this.mapframe.width       = "100%";
		this.mapframe.height      = "100%";
		this.mapframe.frameBorder = "0";
		this.mapframe.src         = this.makeGoogleMapsEmbedURL(this.media_id, this.options.api_key_googlemaps);
		
		
		// After Loaded
		this.onLoaded();
	}
1055404
public function getVideoID($video_link = null, $video_id = null) {
        $result = $this->checkVideo($video_link, $video_id, $part = 'snippet');
        return $result['items'][0]['id'];
    }
1076261
public function searchHulu($searchText)
		{
			global $urlData;

			if (empty($this->dataFile)) {
				$this->dataFile = $this->setDataFile();
			}

			foreach ($this->dataFile as $value) {
				$fileName = $value;
				$doc = new \DOMDocument;
				$doc->preserveWhiteSpace = false;
				$file = realpath($this->dataFolder.'/'.$fileName);
				$doc->load($file);
				$xpath = new \DOMXpath($doc);
				$query = "/*/*[contains(.,' ".$searchText." ')]";
				$results = $xpath->query($query);
				$c = count($this->huluResult);

				foreach ($results as $result) {
					$this->processNode($result);
					$this->huluResult[$c]['loc'] 					= $urlData['url']['loc'];
					$this->huluResult[$c]['thumbnail_loc'] 			= $urlData['video:video']['video:thumbnail_loc'];
					$this->huluResult[$c]['title'] 					= $urlData['video:video']['video:title'];
					$this->huluResult[$c]['description'] 			= $urlData['video:video']['video:description'];
					$this->huluResult[$c]['family_friendly'] 		= $urlData['video:video']['video:family_friendly'];
					$this->huluResult[$c]['duration'] 				= $urlData['video:video']['video:duration'];
					$this->huluResult[$c]['rating'] 				= $urlData['video:video']['video:rating'];
					$this->huluResult[$c]['publication_date'] 		= $urlData['video:video']['video:publication_date'];
					$this->huluResult[$c]['season_number'] 			= $urlData['video:video']['video:season_number'];
					$this->huluResult[$c]['video_type'] 			= $urlData['video:video']['video:video_type'];
					$this->huluResult[$c]['air_date'] 				= $urlData['video:video']['video:air_date'];
					$this->huluResult[$c]['added_date'] 			= $urlData['video:video']['video:added_date'];
					$this->huluResult[$c]['company'] 				= $urlData['video:video']['video:company'];
					$this->huluResult[$c]['requires_subscription'] 	= $urlData['video:video']['video:requires_subscription'];
					$this->huluResult[$c]['content_id'] 			= $urlData['video:video']['hulu-video:content_id'];
					$this->huluResult[$c]['show_id'] 				= $urlData['video:video']['hulu-video:show_id'];
					$this->huluResult[$c]['seriesDescription']	 	= $urlData['video:video']['hulu:seriesDescription'];
					$this->huluResult[$c]['mediaType'] 				= $urlData['video:video']['hulu:mediaType'];
					$this->huluResult[$c]['channel'] 				= $urlData['video:video']['hulu:channel'];
					$this->huluResult[$c]['hulu']['season_number'] 	= $urlData['video:video']['hulu-video:season_number'];
					$this->huluResult[$c]['hulu']['air_date'] 		= $urlData['video:video']['hulu-video:air_date'];
					$this->huluResult[$c]['hulu']['company'] 		= $urlData['video:video']['hulu-video:company'];
					$this->huluResult[$c]['show']['show_title'] 	= $urlData['video:tvshow']['video:show_title'];
					$this->huluResult[$c]['show']['video_type'] 	= $urlData['video:tvshow']['video:video_type'];
					$this->huluResult[$c]['show']['episode_title'] 	= $urlData['video:tvshow']['video:episode_title'];
					$this->huluResult[$c]['show']['premier_date'] 	= $urlData['video:tvshow']['video:premier_date'];
					$c++;
				}

				$doc 	= null;
				$xpath 	= null;
			}
		}
927355
function (stats) {
            if (stats.result) {
              var resultList = stats.result();
              for (var resultIndex = 0; resultIndex < resultList.length; resultIndex++) {
                var result = resultList[resultIndex];

                if (result.stat) {

                  if(result.stat('googActiveConnection') === 'true') {
                    currentStats.localCandidateType = result.stat('googLocalCandidateType');
                    currentStats.remoteCandidateType = result.stat('googRemoteCandidateType');
                    currentStats.transportType = result.stat('googTransportType');
                  }

                  parseAudioStats(result);
                  parseVideoStats(result);
                }
              }
            }

            completion(null, currentStats);
          }
1063783
private void processVideoStbl(SampleTableBox stbl, long scale) {
        // stsc - has Records
        SampleToChunkBox stsc = stbl.getSampleToChunkBox(); // stsc
        if (stsc != null) {
            log.debug("Sample to chunk atom found");
            videoSamplesToChunks = stsc.getEntries();
            log.debug("Video samples to chunks: {}", videoSamplesToChunks.size());
            for (SampleToChunkBox.Entry s2c : videoSamplesToChunks) {
                log.info("Entry: {}", s2c);
            }
        }
        // stsz - has Samples
        SampleSizeBox stsz = stbl.getSampleSizeBox(); // stsz
        if (stsz != null) {
            log.debug("Sample size atom found");
            videoSamples = stsz.getSampleSizes();
            // if sample size is 0 then the table must be checked due to variable sample sizes
            log.debug("Sample size: {}", stsz.getSampleSize());
            videoSampleCount = stsz.getSampleCount();
            log.debug("Sample count: {}", videoSampleCount);
        }
        // stco - has Chunks
        ChunkOffsetBox stco = stbl.getChunkOffsetBox(); // stco / co64
        if (stco != null) {
            log.debug("Chunk offset atom found");
            videoChunkOffsets = stco.getChunkOffsets();
            log.debug("Chunk count: {}", videoChunkOffsets.length);
        } else {
            // co64 - has Chunks
            List<ChunkOffset64BitBox> stblBoxes = stbl.getBoxes(ChunkOffset64BitBox.class);
            if (stblBoxes != null && !stblBoxes.isEmpty()) {
                ChunkOffset64BitBox co64 = stblBoxes.get(0);
                if (co64 != null) {
                    log.debug("Chunk offset (64) atom found");
                    videoChunkOffsets = co64.getChunkOffsets();
                    log.debug("Chunk count: {}", videoChunkOffsets.length);
                    // double the timescale for video, since it seems to run at
                    // half-speed when co64 is used (seems hacky)
                    //videoTimeScale = scale * 2.0;
                    //log.debug("Video time scale: {}", videoTimeScale);
                }
            }
        }
        // stss - has Sync - no sync means all samples are keyframes
        SyncSampleBox stss = stbl.getSyncSampleBox(); // stss
        if (stss != null) {
            log.debug("Sync sample atom found");
            syncSamples = stss.getSampleNumber();
            log.debug("Keyframes: {}", syncSamples.length);
        }
        // stts - has TimeSampleRecords
        TimeToSampleBox stts = stbl.getTimeToSampleBox(); // stts
        if (stts != null) {
            log.debug("Time to sample atom found");
            List<TimeToSampleBox.Entry> records = stts.getEntries();
            log.debug("Video time to samples: {}", records.size());
            // handle instance where there are no actual records (bad f4v?)
            if (records.size() > 0) {
                TimeToSampleBox.Entry rec = records.get(0);
                log.debug("Samples = {} delta = {}", rec.getCount(), rec.getDelta());
                //if we have 1 record it means all samples have the same duration
                videoSampleDuration = rec.getDelta();
            }
        }
        // ctts - (composition) time to sample
        CompositionTimeToSample ctts = stbl.getCompositionTimeToSample(); // ctts
        if (ctts != null) {
            log.debug("Composition time to sample atom found");
            compositionTimes = ctts.getEntries();
            log.debug("Record count: {}", compositionTimes.size());
            if (log.isTraceEnabled()) {
                for (CompositionTimeToSample.Entry rec : compositionTimes) {
                    double offset = rec.getOffset();
                    if (scale > 0d) {
                        offset = (offset / (double) scale) * 1000.0;
                        rec.setOffset((int) offset);
                    }
                    log.trace("Samples = {} offset = {}", rec.getCount(), rec.getOffset());
                }
            }
        }
        // sdtp - sample dependency type
        SampleDependencyTypeBox sdtp = stbl.getSampleDependencyTypeBox(); // sdtp
        if (sdtp != null) {
            log.debug("Independent and disposable samples atom found");
            List<SampleDependencyTypeBox.Entry> recs = sdtp.getEntries();
            for (SampleDependencyTypeBox.Entry rec : recs) {
                log.debug("{}", rec);
            }
        }
    }
656389
function HttpViewResult(name, data)
{
    this.name = name;
    this.data = data===undefined? []: data;
    this.contentType = 'text/html;charset=utf-8';
    this.contentEncoding = 'utf8';
}
563128
private void initAdapter() {
    RandomVideoCollectionGenerator randomVideoCollectionGenerator =
        new RandomVideoCollectionGenerator();
    AdapteeCollection<Video> videoCollection =
        randomVideoCollectionGenerator.generateListAdapteeVideoCollection(VIDEO_COUNT);
    adapter = new RendererAdapter<Video>(new VideoRendererBuilder(), videoCollection);
  }
1102568
def _get_video_id(self, url=None):
        
        if url:
            html_data = self.http.request("get", url).text
        else:
            html_data = self.get_urldata()
        html_data = self.get_urldata()
        match = re.search(r'data-video-id="([0-9]+)"', html_data)
        if match:
            return match.group(1)
        match = re.search(r'data-videoid="([0-9]+)', html_data)
        if match:
            return match.group(1)
        match = re.search(r'"mediaGuid":"([0-9]+)"', html_data)
        if match:
            return match.group(1)

        clips = False
        slug = None
        match = re.search('params":({.*}),"query', self.get_urldata())
        if match:
            jansson = json.loads(match.group(1))
            if "seasonNumberOrVideoId" in jansson:
                season = jansson["seasonNumberOrVideoId"]
                match = re.search(r"\w-(\d+)$", season)
                if match:
                    season = match.group(1)
            else:
                match = self._conentpage(self.get_urldata())
                if match:  # this only happen on the program page?
                    janson2 = json.loads(match.group(1))
                    if janson2["formatPage"]["format"]:
                        season = janson2["formatPage"]["format"]["seasonNumber"]
                        return janson2["formatPage"]["format"]["videos"][str(season)]["program"][0]["id"]
                return None
            if "videoIdOrEpisodeNumber" in jansson:
                videp = jansson["videoIdOrEpisodeNumber"]
                match = re.search(r'(\w+)-(\d+)', videp)
                if match:
                    episodenr = match.group(2)
                else:
                    episodenr = videp
                    clips = True
                match = re.search(r'(s\w+)-(\d+)', season)
                if match:
                    season = match.group(2)
            else:
                # sometimes videoIdOrEpisodeNumber does not work.. this is a workaround
                match = re.search(r'(episode|avsnitt)-(\d+)', self.url)
                if match:
                    episodenr = match.group(2)
                else:
                    episodenr = season
            if "slug" in jansson:
                slug = jansson["slug"]

            if clips:
                return episodenr
            else:
                match = self._conentpage(self.get_urldata())
                if match:
                    janson = json.loads(match.group(1))
                    for i in janson["formatPage"]["format"]["videos"].keys():
                        if "program" in janson["formatPage"]["format"]["videos"][str(i)]:
                            for n in janson["formatPage"]["format"]["videos"][i]["program"]:
                                if str(n["episodeNumber"]) and int(episodenr) == n["episodeNumber"] and int(season) == n["seasonNumber"]:
                                    if slug is None or slug == n["formatSlug"]:
                                        return n["id"]
                                elif n["id"] == episodenr:
                                    return episodenr

        parse = urlparse(self.url)
        match = re.search(r'/\w+/(\d+)', parse.path)
        if match:
            return match.group(1)
        match = re.search(r'iframe src="http://play.juicyplay.se[^\"]+id=(\d+)', html_data)
        if match:
            return match.group(1)

        match = re.search(r'<meta property="og:image" content="([\S]+)"', html_data)
        if match:
            return match.group(1).split("/")[-2]

        return None
275571
private final void playLive() throws IOException {
        // change state
        subscriberStream.setState(StreamState.PLAYING);
        IMessageInput in = msgInReference.get();
        IMessageOutput out = msgOutReference.get();
        if (in != null && out != null) {
            // get the stream so that we can grab any metadata and decoder configs
            IBroadcastStream stream = (IBroadcastStream) ((IBroadcastScope) in).getClientBroadcastStream();
            // prevent an NPE when a play list is created and then immediately flushed
            int ts = 0;
            if (stream != null) {
                Notify metaData = stream.getMetaData();
                //check for metadata to send
                if (metaData != null) {
                    ts = metaData.getTimestamp();
                    log.debug("Metadata is available");
                    RTMPMessage metaMsg = RTMPMessage.build(metaData, metaData.getTimestamp());
                    sendMessage(metaMsg);
                } else {
                    log.debug("No metadata available");
                }
                IStreamCodecInfo codecInfo = stream.getCodecInfo();
                log.debug("Codec info: {}", codecInfo);
                if (codecInfo instanceof StreamCodecInfo) {
                    StreamCodecInfo info = (StreamCodecInfo) codecInfo;
                    // handle video codec with configuration
                    IVideoStreamCodec videoCodec = info.getVideoCodec();
                    log.debug("Video codec: {}", videoCodec);
                    if (videoCodec != null) {
                        // check for decoder configuration to send
                        IoBuffer config = videoCodec.getDecoderConfiguration();
                        if (config != null) {
                            log.debug("Decoder configuration is available for {}", videoCodec.getName());
                            VideoData conf = new VideoData(config, true);
                            log.debug("Pushing video decoder configuration");
                            sendMessage(RTMPMessage.build(conf, ts));
                        }
                        // check for keyframes to send
                        FrameData[] keyFrames = videoCodec.getKeyframes();
                        for (FrameData keyframe : keyFrames) {
                            log.debug("Keyframe is available");
                            VideoData video = new VideoData(keyframe.getFrame(), true);
                            log.debug("Pushing keyframe");
                            sendMessage(RTMPMessage.build(video, ts));
                        }
                    } else {
                        log.debug("No video decoder configuration available");
                    }
                    // handle audio codec with configuration
                    IAudioStreamCodec audioCodec = info.getAudioCodec();
                    log.debug("Audio codec: {}", audioCodec);
                    if (audioCodec != null) {
                        // check for decoder configuration to send
                        IoBuffer config = audioCodec.getDecoderConfiguration();
                        if (config != null) {
                            log.debug("Decoder configuration is available for {}", audioCodec.getName());
                            AudioData conf = new AudioData(config.asReadOnlyBuffer());
                            log.debug("Pushing audio decoder configuration");
                            sendMessage(RTMPMessage.build(conf, ts));
                        }
                    } else {
                        log.debug("No audio decoder configuration available");
                    }
                }
            }
        } else {
            throw new IOException(String.format("A message pipe is null - in: %b out: %b", (msgInReference == null), (msgOutReference == null)));
        }
        configsDone = true;
    }
722422
@Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video_sample);
    ButterKnife.inject(this);
    initializeVideoView();
    initializePoster();
    hookDraggableViewListener();
  }