def run(self): """ run """ count = 1 while count <= self.opts.visits: youtube = YouTube(url=self.opts.url, proxy=self.opts.proxy, verbose=self.opts.verbose) youtube.get_url() title = youtube.get_title() if self.opts.visits > 1 and title: length = (len(title) + 4 - len(str(count))) print('[{0}] {1}'.format(count, '-' * length)) ip_address = utils.get_ipaddr(proxy=self.opts.proxy) if ip_address: print('external IP address:', ip_address) if title: print('title:', title) youtube.play_video() youtube.get_views() video_duration = youtube.time_duration() if video_duration: print('video duration time:', video_duration) seconds = utils.to_seconds(duration=video_duration.split(':')) if seconds: sleep_time = randrange(seconds) if self.opts.verbose: print('video duration time in seconds:', seconds) print('stopping video in %s seconds' % sleep_time) time.sleep(sleep_time) youtube.disconnect() count += 1