Tries to find a video file that belongs to an RTDC dataset

        Returns None if no video file is found.
17281
def find_video_file(rtdc_dataset):
        
        video = None
        if rtdc_dataset._fdir.exists():
            # Cell images (video)
            videos = [v.name for v in rtdc_dataset._fdir.rglob("*.avi")]
            # Filter videos according to measurement number
            meas_id = rtdc_dataset._mid
            videos = [v for v in videos if v.split("_")[0] == meas_id]
            videos.sort()
            if len(videos) != 0:
                # Defaults to first avi file
                video = videos[0]
                # g/q video file names. q comes first.
                for v in videos:
                    if v.endswith("imag.avi"):
                        video = v
                        break
                    # add this here, because fRT-DC measurements also contain
                    # videos ..._proc.avi
                    elif v.endswith("imaq.avi"):
                        video = v
                        break
        if video is None:
            return None
        else:
            return rtdc_dataset._fdir / video
242743
def find_resource(r, *, pkg='cyther'):
    
    file_path = pkg_resources.resource_filename(pkg, os.path.join('test', r))
    if not os.path.isfile(file_path):
        msg = "Resource '{}' does not exist"
        raise FileNotFoundError(msg.format(file_path))
    return file_path
1099017
def _search(self, limit, format):
        '''
        
        '''
        url = self.QUERY_URL.format(requests.utils.quote("'{}'".format(self.query)), min(50, limit), self.current_offset, format)
        r = requests.get(url, auth=("", self.api_key))
        try:
            json_results = r.json()
        except ValueError as vE:
            if not self.safe:
                raise PyBingVideoException("Request returned with code %s, error msg: %s" % (r.status_code, r.text))
            else:
                print ("[ERROR] Request returned with code %s, error msg: %s. \nContinuing in 5 seconds." % (r.status_code, r.text))
                time.sleep(5)
        packaged_results = [VideoResult(single_result_json) for single_result_json in json_results['d']['results']]
        self.current_offset += min(50, limit, len(packaged_results))
        return packaged_results
882060
def _find_datastream(self, name):
        """"""
        for stream in self.data_streams: #search to see if this is a new datastream or a known one
            if stream.name == name:
                return stream
        return None
258777
async def find_movie(self, query):
        
        params = OrderedDict([
            ('query', query), ('include_adult', False),
        ])
        url = self.url_builder('search/movie', {}, params)
        data = await self.get_data(url)
        if data is None:
            return
        return [
            Movie.from_json(item, self.config['data'].get('images'))
            for item in data.get('results', [])
        ]
1012346
def get_video(self, node):
        
        video = Video()
        video.embed_code = self.get_embed_code(node)
        video.embed_type = self.get_embed_type(node)
        video.width = self.get_width(node)
        video.height = self.get_height(node)
        video.src = self.get_src(node)
        video.provider = self.get_provider(video.src)
        return video
673242
def compose_from_srts(srts, search, searchtype):
    
    composition = []
    foundSearchTerm = False

    # Iterate over each subtitles file.
    for srt in srts:

        print(srt)
        lines = clean_srt(srt)

        videofile = ""
        foundVideoFile = False

        print("[+] Searching for video file corresponding to '" + srt + "'.")
        for ext in usable_extensions:
            tempVideoFile = srt.replace('.srt', '.' + ext)
            if os.path.isfile(tempVideoFile):
                videofile = tempVideoFile
                foundVideoFile = True
                print("[+] Found '" + tempVideoFile + "'.")

        # If a correspndong video file was found for this subtitles file...
        if foundVideoFile:

            # Check that the subtitles file contains subtitles.
            if lines:

                # Iterate over each line in the current subtitles file.
                for timespan in lines.keys():
                    line = lines[timespan].strip()

                    # If this line contains the search term
                    if search_line(line, search, searchtype):

                        foundSearchTerm = True

                        # Extract the timespan for this subtitle.
                        start, end = convert_timespan(timespan)

                        # Record this occurance of the search term.
                        composition.append({'file': videofile, 'time': timespan, 'start': start, 'end': end, 'line': line})

                # If the search was unsuccessful.
                if foundSearchTerm is False:
                    print("[!] Search term '" + search + "'" + " was not found is subtitle file '" + srt + "'.")

            # If no subtitles were found in the current file.
            else:
                print("[!] Subtitle file '" + srt + "' is empty.")

        # If no video file was found...
        else:
            print("[!] No video file was found which corresponds to subtitle file '" + srt + "'.")
            print("[!] The following video formats are currently supported:")
            extList = ""
            for ext in usable_extensions:
                extList += ext + ", "
            print(extList)

    return composition
491080
def find_datafile(self, name, search_path=None):
        
        if not search_path:
            search_path = self.define_dir

        return codec.find_datafile(name, search_path)
84342
def find_all(_connection=None, page_size=100, page_number=0,
        sort_by=enums.DEFAULT_SORT_BY, sort_order=enums.DEFAULT_SORT_ORDER):
        
        return connection.ItemResultSet('find_all_videos', Video,
            _connection, page_size, page_number, sort_by, sort_order)
1323393
def _get_video(edx_video_id):
    
    try:
        return Video.objects.prefetch_related("encoded_videos", "courses").get(edx_video_id=edx_video_id)
    except Video.DoesNotExist:
        error_message = u"Video not found for edx_video_id: {0}".format(edx_video_id)
        raise ValVideoNotFoundError(error_message)
    except Exception:
        error_message = u"Could not get edx_video_id: {0}".format(edx_video_id)
        logger.exception(error_message)
        raise ValInternalError(error_message)
547588
def get_video_end_time(video_file):
    """"""
    if not os.path.isfile(video_file):
        print("Error, video file {} does not exist".format(video_file))
        return None
    try:
        time_string = FFProbe(video_file).video[0].creation_time
        try:
            creation_time = datetime.datetime.strptime(
                time_string, TIME_FORMAT)
        except:
            creation_time = datetime.datetime.strptime(
                time_string, TIME_FORMAT_2)
    except:
        return None
    return creation_time
165130
def detectFps(self, movieFile = None, default = 23.976):
        """"""

        if movieFile is None:
            movieFile = self._searchForMovieFile()
        return File.detectFpsFromMovie(movieFile, default)
1129079
def get_course_video_image_url(course_id, edx_video_id):
    
    try:
        video_image = CourseVideo.objects.select_related('video_image').get(
            course_id=course_id, video__edx_video_id=edx_video_id
        ).video_image
        return video_image.image_url()
    except ObjectDoesNotExist:
        return None
413047
def get(video_id)
      params = {:id => video_id, :part => 'snippet,statistics'}
      request = Yourub::REST::Videos.list(self,params)
      Yourub::Result.format(request).first
    end
934851
def update_video(self):
        
        window_start = self.parent.value('window_start')
        window_length = self.parent.value('window_length')
        d = self.parent.info.dataset

        videos, begsec, endsec = d.read_videos(window_start,
                                               window_start + window_length)
        
        lg.debug(f'Video: {begsec} - {endsec}')
        self.endsec = endsec
        videos = [str(v) for v in videos]  # make sure it's a str (not path)
        medialist = vlc.MediaList(videos)
        self.medialistplayer.set_media_list(medialist)

        self.cnt_video = 0
        self.n_video = len(videos)

        self.t = QTimer()
        self.t.timeout.connect(self.check_if_finished)
        self.t.start(100)

        self.medialistplayer.play()
        self.mediaplayer.set_time(int(begsec * 1000))
676441
def _find_already_built_wheel(metadata_directory):
    
    if not metadata_directory:
        return None
    metadata_parent = os.path.dirname(metadata_directory)
    if not os.path.isfile(pjoin(metadata_parent, WHEEL_BUILT_MARKER)):
        return None

    whl_files = glob(os.path.join(metadata_parent, '*.whl'))
    if not whl_files:
        print('Found wheel built marker, but no .whl files')
        return None
    if len(whl_files) > 1:
        print('Found multiple .whl files; unspecified behaviour. '
              'Will call build_wheel.')
        return None

    # Exactly one .whl file
    return whl_files[0]
1019851
def get_video_count(self, search_q=None):
        ''''''
        if search_q is not None:
            params = {'q': search_q}
        else:
            params = None

        url = "/counts/videos"
        result = self._make_request(self.CMS_Server, 'GET', url, params=params)
        return result['count']