<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def obtainInfo(self):
 """ Method for obtaining information about the movie. """


        try:
            info = self.ytdl.extract_info(self.yid, download=False)
        except youtube_dl.utils.DownloadError:
            raise ConnectionError

        if not self.preferences['stream']:
            self.url = (info['requested_formats'][0]['url'], info['requested_formats'][1]['url'])
            return True

        # else:
        for f in info['formats']:
            if 'filesize' not in f or not f['filesize']:
                f['filesize'] = float('inf') # next line won't fail, infinity, because unknown filesize is the least preferred

        # - for easy sorting - we'll get best quality and lowest filsize
        aud = {(-int(f['abr']),    f['filesize'], f['url']) for f in info['formats'] if f.get('abr') and not f.get('height')}
        vid = {(-int(f['height']), f['filesize'], f['url']) for f in info['formats'] if not f.get('abr') and f.get('height')}
        full= {(-int(f['height']), f['filesize'], f['url']) for f in info['formats'] if f.get('abr') and f.get('height')}

        try:
            _f = int( self.preferences.get('format') ) # if valid format is present, then choose closes value
            _k = lambda x: abs(x[0] + _f) # +, because x[0] is negative

        except (ValueError, TypeError):
            _k = lambda d: d

        if self.preferences['audio'] and self.preferences['video']: fm = sorted(full, key=_k)
        elif self.preferences['audio']: fm = sorted(aud, key=_k)
        elif self.preferences['video']: fm = sorted(vid, key=_k)

        filesize = 0
        i = -1

        try:
            while filesize == 0: # some videos are problematic, we will try to find format with non-zero filesize

                i += 1

                self.url = fm[i][2]
                if fm[i][1] == float('inf'):
                    filesize = int(self.r_session.head(self.url).headers['content-length'])
                else:
                    filesize = int(fm[i][1])

        except IndexError: # finding filesize failed for every format

            self.url = (info['requested_formats'][0]['url'], info['requested_formats'][1]['url'])
            self.preferences['stream'] = False # hopefully non-stream download will work

            return True

        self.filesize = filesize

        return True