def extract_video_tweets(twapi_search_response: dict) -> List[Video]: video_list = [] for tweet in twapi_search_response: selected_video = select_video_url_from_tweet(tweet) if selected_video is None: continue else: video_url = selected_video[0] video_type = selected_video[1] if "retweeted_status" in tweet or "quoted_status" in tweet: if "retweeted_status" in tweet: video_source_tweet = tweet["retweeted_status"] elif "quoted_status" in tweet: video_source_tweet = tweet["quoted_status"] author = User( user_id=video_source_tweet["user"]["id"], name=video_source_tweet["user"]["name"], screen_name=video_source_tweet["user"]["screen_name"], thumbnail_url=video_source_tweet["user"]["profile_image_url_https"]) retweeter = User( user_id=tweet["user"]["id"], name=tweet["user"]["name"], screen_name=tweet["user"]["screen_name"], thumbnail_url=tweet["user"]["profile_image_url_https"]) vid = Video( tweet_id=tweet["id"], author=author, retweeted_user=retweeter, body=video_source_tweet["full_text"], created_at=twitter_date_to_datetime(tweet["created_at"]), video_url=video_url, video_type=video_type) else: author = User( user_id=tweet["user"]["id"], name=tweet["user"]["name"], screen_name=tweet["user"]["screen_name"], thumbnail_url=tweet["user"]["profile_image_url_https"]) vid = Video( tweet_id=tweet["id"], author=author, retweeted_user=None, body=tweet["full_text"], created_at=twitter_date_to_datetime(tweet["created_at"]), video_url=video_url, video_type=video_type) video_list.append(vid) return video_list
def test_create_duplicates(self): ''' Tests raise exception with trying to create duplicates. ''' configure_for_unittest() from model import Video from neomodel import UniqueProperty video1 = Video(link='https://vk.com/blablabla').save() video2 = Video(link='vk.com/blablabla') with self.assertRaises(UniqueProperty): video2.save()
def import_from_lines(self, lines): """ 从多行数据录入数据库 :param lines: 待处理数据 :return: 读取到的记录数量,成功录入的记录数量 """ (total, succ) = (0, 0) for line in lines: total += 1 items = line.strip().split('\t') # 如果所读取的文件编码不为 utf-8,则需要 line.encode('<the_coding_of_str>').decode('utf-8').strip().split('\t') if len(items) < 7: CrawlerLogger.logger.info( 'line format error: {0}'.format(line)) continue tmp_video = Video(0, items[0], items[1], items[2], items[3], items[4], items[5], items[6]) if not self.insert_one_video(tmp_video): CrawlerLogger.logger.info( 'insert line failed: {0}'.format(line)) else: succ += 1 return total, succ
def add(user_id, video_id): #Taking the old video ti present it to the user and also to mention the video last publisher to post it #Interactivly user = session.query(User).filter_by(id = user_id).first() curr_video = session.query(Video).filter_by(id = video_id).first() if request.method == 'GET': return render_template('add.html', user_id = user_id, video_id = video_id) #Adding the video with refrence to the old one else: video = request.form.get('video') description = request.form.get('description') owner = user.id curr_video.other_video = video publish = False new_vid = Video(video = video, description = description, publish = publish, owner = owner) session.add(new_vid) session.commit() return redirect(url_for('homepage',user_id = user_id))
def load_videos(): """Load videos from seed data into database""" with open("seed_data/videos.txt") as videos: for row in videos: video = row.rstrip().split("|") youtube = True if video[4] == "True" else False hidden = True if video[5] == "True" else False kwargs = dict( video_id = video[0], user_id = video[1], video = video[2], category = video[3], youtube = youtube, hidden = hidden ) keys_to_remove = [] for key in kwargs.keys(): if kwargs[key] == "": keys_to_remove.append(key) for key in keys_to_remove: del kwargs[key] video = Video(**kwargs) db.session.add(video) db.session.commit()
def openFile(self, filename): filetype = filename.split('.')[-1] self.generateButton.setText("Loading...") self.infoLabel.setText("File opened: " + filename) print("Opening " + filename) # start the video player or start a worker thread depending on file type if filetype in self.videofiletypes: self.currentFile = Video(filepath=filename, colortype="rgb") self.generateButton.setText("Generate images from video") self.generateButton.setDisabled(False) self.startVideoPlayer() elif filetype in self.metadatatypes: self.metafilename = filename self.startWorker(ip.loadCsv, self.setCurrentFrames, self.fillGallery, self.metafilename, self.currentFrames) elif filetype == 'pkl': self.currentFile = filename self.startWorker(ip.loadPickle, self.setCurrentFrames, self.fillGallery, self.currentFile) elif filetype == 'h5': self.currentFile = filename self.startWorker(ip.loadhdf5, self.setCurrentFrames, self.fillGallery, self.currentFile, self.currentFrames) else: # invalid file type selected self.showWarning('FileType')
def test_get_episode(self): ''' Tests getting episode from video's field. ''' configure_for_unittest() from model import Video, Show, Season, Episode show = Show(title='House of Cards').save() season1 = Season(show=show, number=1).save() season2 = Season(show=show, number=2).save() episode1 = Episode(season=season1, number=1, release_date=dt(2010, 1, 1)).save() episode2 = Episode(season=season1, number=2).save() episode3 = Episode(season=season2, number=1).save() video = Video(link='vk.com').save() show.seasons.connect(season1) show.seasons.connect(season2) season1.episodes.connect(episode1) season1.episodes.connect(episode2) season2.episodes.connect(episode3) episode1.videos.connect(video) video.refresh() self.assertEqual(video.episode.get().number, 1)
def main(): alpha_values = np.linspace(1.5, 3, 20) rho_values = np.logspace(-2, -0.1, 20) # Ensure cache video = Video("../datasets/AICity_data/train/S03/c010/frames") get_background_model(video, int(2141 * 0.25), total_frames=int(2141 * 0.25), disable_tqdm=False) # Best alpha: 1.75 # mAP_list = Parallel(n_jobs=4)(delayed(w2_map_alpha)(alpha) for alpha in tqdm(alpha_values)) mAP_list = Parallel(n_jobs=3)(delayed(w2_map_alpha)(1.75, rho) for rho in tqdm(rho_values)) """mAP_list = [0.18656629994209614, 0.23257430508572247, 0.2333781161367368, 0.18301435406698566, 0.1773032336790726, 0.1762025561112319, 0.12792207792207794, 0.17066218427456575, 0.12438077386530996, 0.12091293755609694, 0.11872632575757576, 0.1189064558629776, 0.15132634758802985, 0.157589106928314, 0.26284443191338397, 0.39380709780347006, 0.43192630414348515, 0.357941584643725, 0.3186317361126976, 0.20596422790608496]""" plt.figure() plt.plot(rho_values, mAP_list) plt.xlabel(r'$\rho$ threshold') plt.ylabel('mAP') plt.show()
def create_video(link, title, notes = ""): """Create and return a video.""" video = Video(link = link, title = title, notes = notes) db.session.add(video) db.session.commit() return video
def create_video(video_path, description, date_posted): """Create new video (info).""" video = Video(video_path=video_path, description=description, date_posted=date_posted) db.session.add(video) db.session.commit() return video
def upload_video(): """Handle file uploads""" # if it's a get - render registration form if request.method == "GET": """Load form for user to upload new video""" case_id = request.args.get('case_id') return render_template('upload-video.html', case_id=case_id) # otherwise register user in db if request.method == "POST": """Uploads video to aws""" print "\n\n\n\n\n\n\n", request, "\n\n\n\n\n\n" video_file = request.files['media'] print "\n\n\n\n\n\n\n", video_file, "\n\n\n\n\n\n" case_id = request.form.get('case_id') # video_file = request.files.get("rawvid") video_name = video_file.filename try: transcript_file = request.files.get("tscript") except: transcript_file = None user_id = g.current_user.user_id #get deponent name and recorded date deponent = request.form.get('name') recorded_at = request.form.get('date-taken') # add the video to the db date_added = datetime.now() new_vid = Video(case_id=case_id, vid_name=video_name, added_by=user_id, added_at=date_added, deponent=deponent, recorded_at=recorded_at) db.session.add(new_vid) db.session.commit() if transcript_file: script_text = transcript_file.readlines() new_script = Transcript(vid_id=new_vid.vid_id, text=script_text) db.session.add(new_script) db.session.commit() # send the upload to a separate thread to upload while the user moves on upload = threading.Thread(target=upload_aws_db, args=(video_file, video_name, case_id, user_id, socketio)).start() return jsonify(case_id)
def create_video(channel_name, web_title, youtube_title): video = Video(channel_name=channel_name, web_title=web_title, youtube_title=youtube_title) db.session.add(video) db.session.commit() return video
def update_episode_urls(episode): urls, new_urls = get_episode_urls(episode), [] for url in urls: try: v = Video(link=url).save() episode.videos.connect(v) new_urls.append(urls) except neomodel.UniqueProperty: pass return new_urls
def stabilization(optical_flow_method, debug: bool = False, **kwargs): """ Perform video stabilization using the given optical flow method. Idea: test some metric using a known logo. Using ORB matching we could detect if it moves. :param optical_flow_method: the optical flow method to use :param debug: whether to show debug plots """ video = Video('../datasets/stabilization/piano') feature_params = dict(maxCorners=500, qualityLevel=0.3, minDistance=7, blockSize=7) previous_frame = None accum_flow = np.zeros(2) count = 0 for i, frame in tqdm(enumerate(video.get_frames()), total=len(video), file=sys.stdout): rows, cols, _ = frame.shape if previous_frame is not None: if i % 4 == 0: p0 = cv2.goodFeaturesToTrack(cv2.cvtColor( previous_frame, cv2.COLOR_BGR2GRAY), mask=None, **feature_params) flow = optical_flow_method(previous_frame, frame, p0) if debug: show_optical_flow_arrows(previous_frame, flow) m = np.mean(flow[np.logical_or(flow[:, :, 0] != 0, flow[:, :, 1] != 0)], axis=(0, 1)) if not np.isnan(accum_flow).any(): accum_flow += -m transform = np.float32([[1, 0, accum_flow[0]], [0, 1, accum_flow[1]]]) frame2 = cv2.warpAffine(frame, transform, (cols, rows)) if debug: plt.figure() plt.imshow(cv2.cvtColor(frame2, cv2.COLOR_BGR2RGB)) plt.axis('off') plt.show() cv2.imwrite("../video/block/OrigianlFrame%04d.jpg" % count, frame) # save frame as JPEG file cv2.imwrite("../video/block/StabilizedFrame%04d.jpg" % count, frame2) # save frame as JPEG file count += 1 previous_frame = frame
def w2_map_alpha(alpha): video = Video("../datasets/AICity_data/train/S03/c010/frames") frames = [] ious = [] for im, mask, frame in week2_nonadaptive(video, alpha, disable_tqdm=True): frames.append(frame) ious.append(frame.get_detection_iou_mean(ignore_classes=True)) mAP = mean_average_precision(frames) print('alpha', alpha, 'mAP', mAP, 'mean IoU', np.mean(ious)) return mAP
def add_video(): """add video to database""" user_id = session["current_user"] category = request.form.get("category") youtube = request.form.get("youtube") print(category) print(youtube) if youtube: kwargs = dict(user_id=user_id, video=youtube, category=category, youtube=True) db.session.add(Video(**kwargs)) db.session.commit() print("added youtube") else: video = functions.save_photo("video") print(video) kwargs = dict(user_id=user_id, video=video, category=category, youtube=False) db.session.add(Video(**kwargs)) db.session.commit() print("added vid") user = User.query.get(user_id) for vid in user.videos: print(vid.video, vid.category, vid.youtube) return redirect("/users/{}/my_videos".format(user_id))
def upload(): if 'video' not in request.files: return json_error("Video file not found") video_file = request.files['video'] filename = secure_filename(video_file.filename) ext = filename.split('.')[-1] new_filename = generate_random_string() + '.' + ext video_file.save(os.path.join(app.config['UPLOAD_DIR'], new_filename)) video = Video(filename=new_filename) video.save() return jsonify(video.to_dict())
def create_video(video_title, video_duration, video_url, playlist_id): """Create and return a new video to a playlist""" video = Video( video_title=video_title, video_duration=video_duration, video_url=video_url, playlist_id=playlist_id, ) db.session.add(video) db.session.commit() return video
def fine_tune_yolo(debug=False): video = Video("../datasets/AICity_data/train/S03/c010/frames") detection_transform = DetectionTransform() classes = utils.load_classes('../config/coco.names') hyperparams = parse_model_config('../config/yolov3.cfg')[0] learning_rate = float(hyperparams["learning_rate"]) momentum = float(hyperparams["momentum"]) decay = float(hyperparams["decay"]) burn_in = int(hyperparams["burn_in"]) model = Darknet('../config/yolov3.cfg') print(model) model.load_weights('../weights/yolov3.weights') model.train() for module_def, module in zip(model.module_defs, model.module_list): if module_def["type"] == "yolo": break module.train(False) if torch.cuda.is_available(): model = model.cuda() optimizer = Adam(filter(lambda p: p.requires_grad, model.parameters()), lr=1e-5) gt = read_annotations( '../datasets/AICity_data/train/S03/c010/m6-full_annotation.xml') dataset = YoloDataset(video, gt, classes, transforms=detection_transform) data_loader = DataLoader(dataset, batch_size=16, shuffle=True, num_workers=4) for epoch in tqdm(range(10), file=sys.stdout, desc='Fine tuning'): for images, targets in tqdm(data_loader, file=sys.stdout, desc='Running epoch'): if torch.cuda.is_available(): images = images.cuda() targets = targets.cuda() optimizer.zero_grad() loss = model(images, targets) loss.backward() optimizer.step() print('Training finished. Saving weights...') model.save_weights('../weights/fine_tuned_yolo_freeze.weights') print('Saved weights')
def youtube_search(q, year='', limit=1): youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION, developerKey=DEVELOPER_KEY) search_response = youtube.search().list(q=q + str(year) + ' trailer', part='id, snippet', maxResults=limit).execute() videos = [] for search_result in search_response.get('items', []): if search_result['id']['kind'] == 'youtube#video': video = Video(video_id=search_result['id']['videoId'], thumbnail=search_result['snippet']['thumbnails'] ['medium']['url']).to_dict() videos.append(video) return videos
def post(self, playlist_id): if PlayList.query.filter_by( id=playlist_id).first().owner_id != User.query.filter_by( login=auth.username()).first().id: abort(404, message="Not your playlist") args = video_put_args.parse_args() result = PlayList.query.filter_by(id=playlist_id).first() video = Video(url=args['url']) result.videos.append(video) result = db.session.merge(result) db.session.add(result, video) db.session.commit() return Video.query.filter_by(url=args['url']).first(), 201
def main(): alpha_values = np.linspace(1.5, 3, 20) # Ensure cache video = Video("../datasets/AICity_data/train/S03/c010/frames") get_background_model(video, int(2141 * 0.25), total_frames=int(2141 * 0.25), disable_tqdm=False) mAP_list = Parallel(n_jobs=4)(delayed(w2_map_alpha)(alpha) for alpha in tqdm(alpha_values)) # for alpha in tqdm(alpha_values, file=sys.stdout, desc='Global loop....'): # mAP_list.append(w2_map_alpha(alpha)) plt.figure() plt.plot(alpha_values, mAP_list) plt.xlabel(r'$\alpha$ threshold') plt.ylabel('mAP') plt.savefig('map_alpha.png') plt.show()
def main(): design_patterns = Topic('Design Patterns') patterns_intro = Lecture('Intro to Design Patterns') design_patterns.add_module(patterns_intro) composite = Topic('Composite Pattern') design_patterns.add_module(composite) composite_intro = Lecture('Intro to Composite Pattern') composite.add_module(composite_intro) composite_video = Video("Let's compose!") composite.add_module(composite_video) observer = Topic('Iterator Pattern') design_patterns.add_module(observer) observer_intro = Lecture('Intro to Observer Pattern') observer.add_module(observer_intro) design_patterns.display('\t')
def publish(user_id): videos = session.query(Video).all() user = session.query(User).filter_by(id = user_id).first() if request.method == 'GET': return render_template('post.html', user_id = user_id) #Creare new video to publish else: video = request.form.get('video') description = request.form.get('description') owner = user_id if video in videos: return redirect('publish',user_id = user_id) else: new_vid = Video(video = video, description = description, owner = owner) session.add(new_vid) session.commit() return redirect(url_for('homepage',user_id = user_id))
def create_video(channel_name, video_number, video_title, length_hours, length_minutes, length_seconds, views, release_date, comments, likes, dislikes, description, last_updated): video = Video(channel_name=channel_name, video_number=video_number, video_title=video_title, length_hours=length_hours, length_minutes=length_minutes, length_seconds=length_seconds, views=views, release_date=release_date, comments=comments, likes=likes, dislikes=dislikes, description=description, last_updated=last_updated) db.session.add(video) db.session.commit() return video
def test_default(self): ''' Tests responses on messages that are not commands. ''' configure_for_unittest() from command import default, subscribe, unsubscribe, setlanguage, watch from model import Chat, Show, Season, Episode, Video chat = Chat(id=1).save() show = Show(title='House of Cards').save() season1 = Season(show=show, number=1).save() season2 = Season(show=show, number=2).save() episode1 = Episode(season=season1, number=1, release_date=dt(2010, 1, 1)).save() episode2 = Episode(season=season1, number=2).save() episode3 = Episode(season=season2, number=1).save() video1 = Video(link='link to video').save() video2 = Video(link='one more link').save() show.seasons.connect(season1) show.seasons.connect(season2) season1.episodes.connect(episode1) season1.episodes.connect(episode2) season2.episodes.connect(episode3) episode1.videos.connect(video1) episode1.videos.connect(video2) chat.rated_videos.connect(video1, {'value': 1}) bot = FakeBot() upd = FakeUpdate(message=FakeMessage(chat=FakeChat(id=1))) # random input upd.message.text = 'random input' default(bot, upd) self.assertTrue('You can control' in bot.sended_message['text']) # subscribe in 2 steps upd.message.text = '/subscribe' subscribe(bot, upd) upd.message.text = 'house of cards' default(bot, upd) self.assertEqual(bot.sended_message['text'], _('You have subscribed to the show.')) # unsubscribe in 2 steps upd.message.text = '/unsubscribe' unsubscribe(bot, upd) upd.message.text = 'house of cards' default(bot, upd) self.assertEqual(bot.sended_message['text'], _('You have unsubscribed from the show.')) # setlanguage in 2 steps upd.message.text = '/setlanguage' setlanguage(bot, upd) upd.message.text = 'en' default(bot, upd) self.assertEqual(bot.sended_message['text'], _('You are already using this language!')) # watch in 4 steps upd.message.text = '/watch' watch(bot, upd) self.assertEqual(bot.sended_message['text'], _('Which TV show would you like to see?')) upd.message.text = 'house of cards' default(bot, upd) self.assertEqual(bot.sended_message['text'], _('Which season would you like to see?')) upd.message.text = '1' default(bot, upd) self.assertEqual(bot.sended_message['text'], _('Which episode would you like to see?')) upd.message.text = '1' default(bot, upd) self.assertEqual(bot.sended_message['text'], 'link to video') chat.referer = '' chat.save() # positive review - say 'thank you' upd.message.text = '/watch house of cards s1 e1' watch(bot, upd) upd.message.text = Emoji.THUMBS_UP_SIGN default(bot, upd) self.assertEqual(bot.sended_message['text'], _('Thanks for the feedback!'))
def test_rate(self): ''' Tests rating of video. ''' configure_for_unittest() from command import rate from model import Chat, Show, Season, Episode, Video chat = Chat(id=1).save() show = Show(title='House of Cards').save() season1 = Season(show=show, number=1).save() season2 = Season(show=show, number=2).save() episode1 = Episode(season=season1, number=1, release_date=dt(2010, 1, 1)).save() episode2 = Episode(season=season1, number=2).save() episode3 = Episode(season=season2, number=1).save() video1 = Video(link='link to video').save() video2 = Video(link='one more link').save() show.seasons.connect(season1) show.seasons.connect(season2) season1.episodes.connect(episode1) season1.episodes.connect(episode2) season2.episodes.connect(episode3) episode1.videos.connect(video1) episode1.videos.connect(video2) chat.rated_videos.connect(video1, {'value': 1}) bot = FakeBot() upd = FakeUpdate(message=FakeMessage(chat=FakeChat(id=1))) # positive review upd.message.text = ' '.join( ['/rate link to video', unicode(Emoji.THUMBS_UP_SIGN, 'utf-8')]) rate(bot, upd) self.assertEqual(bot.sended_message['text'], _('Thanks for the feedback!')) self.assertEqual(bot.sended_message['chat_id'], 1) self.assertEqual(type(bot.sended_message['reply_markup']), ReplyKeyboardHide) # negative review upd.message.text = ' '.join( ['/rate link to video', unicode(Emoji.THUMBS_DOWN_SIGN, 'utf-8')]) rate(bot, upd) self.assertEqual(bot.sended_message['text'], 'one more link') self.assertEqual(bot.sended_message['chat_id'], 1) self.assertEqual(type(bot.sended_message['reply_markup']), ReplyKeyboardMarkup) self.assertEqual(bot.sended_message['reply_markup'].keyboard, [[Emoji.THUMBS_UP_SIGN, Emoji.THUMBS_DOWN_SIGN]]) # unknown review upd.message.text = ' '.join(['/rate link to video', 'unknown']) rate(bot, upd) self.assertEqual(bot.sended_message['text'], _('Please rate the video.')) self.assertEqual(bot.sended_message['chat_id'], 1) self.assertEqual(type(bot.sended_message['reply_markup']), ReplyKeyboardMarkup) self.assertEqual(bot.sended_message['reply_markup'].keyboard, [[Emoji.THUMBS_UP_SIGN, Emoji.THUMBS_DOWN_SIGN]]) chat.referer = '' chat.save()
def test_watch(self): ''' Tests responses on watch request. ''' configure_for_unittest() from command import watch from model import Chat, Show, Season, Episode, Video chat = Chat(id=1).save() show = Show(title='House of Cards').save() season1 = Season(show=show, number=1).save() season2 = Season(show=show, number=2).save() episode1 = Episode(season=season1, number=1, release_date=dt(2010, 1, 1)).save() episode2 = Episode(season=season1, number=2).save() episode3 = Episode(season=season2, number=1).save() video1 = Video(link='link to video').save() video2 = Video(link='one more link').save() show.seasons.connect(season1) show.seasons.connect(season2) season1.episodes.connect(episode1) season1.episodes.connect(episode2) season2.episodes.connect(episode3) episode1.videos.connect(video1) episode1.videos.connect(video2) chat.rated_videos.connect(video1, {'value': 1}) bot = FakeBot() upd = FakeUpdate(message=FakeMessage(chat=FakeChat(id=1))) # valid request upd.message.text = '/watch house of cards s1 e1' watch(bot, upd) self.assertEqual(bot.sended_message['text'], 'link to video') self.assertEqual(bot.sended_message['chat_id'], 1) self.assertEqual(type(bot.sended_message['reply_markup']), ReplyKeyboardMarkup) self.assertEqual(bot.sended_message['reply_markup'].keyboard, [[Emoji.THUMBS_UP_SIGN, Emoji.THUMBS_DOWN_SIGN]]) chat.referer = '' # bot is waiting for feedback chat.save() # valid request - without arguments upd.message.text = '/watch' watch(bot, upd) chat.refresh() self.assertEqual('/watch', chat.referer) self.assertEqual(bot.sended_message['text'], _('Which TV show would you like to see?')) self.assertEqual(bot.sended_message['chat_id'], 1) self.assertEqual(type(bot.sended_message['reply_markup']), ReplyKeyboardHide) # valid request - continue with show_title upd.message.text = ' '.join([chat.referer, 'house of cards']) watch(bot, upd) chat.refresh() self.assertEqual(chat.referer, '/watch house of cards') self.assertEqual(bot.sended_message['text'], _('Which season would you like to see?')) self.assertEqual(bot.sended_message['chat_id'], 1) self.assertEqual(type(bot.sended_message['reply_markup']), ReplyKeyboardMarkup) self.assertEqual(bot.sended_message['reply_markup'].keyboard, [['1']]) # valid request - continue with seasons number upd.message.text = ' '.join([chat.referer, 's1']) watch(bot, upd) chat.refresh() self.assertEqual(chat.referer, '/watch house of cards s1') self.assertEqual(bot.sended_message['text'], _('Which episode would you like to see?')) self.assertEqual(bot.sended_message['chat_id'], 1) self.assertEqual(type(bot.sended_message['reply_markup']), ReplyKeyboardMarkup) self.assertEqual(bot.sended_message['reply_markup'].keyboard, [['1']]) # valid request - continue with episode number upd.message.text = ' '.join([chat.referer, 'e1']) watch(bot, upd) chat.refresh() self.assertEqual(chat.referer, '/rate link to video') self.assertEqual(bot.sended_message['text'], 'link to video') self.assertEqual(bot.sended_message['chat_id'], 1) self.assertEqual(type(bot.sended_message['reply_markup']), ReplyKeyboardMarkup) self.assertEqual(bot.sended_message['reply_markup'].keyboard, [[Emoji.THUMBS_UP_SIGN, Emoji.THUMBS_DOWN_SIGN]]) chat.referer = '' chat.save() # trying to watch non-existent TV show upd.message.text = '/watch kitchen' watch(bot, upd) self.assertEqual(bot.sended_message['text'], _('This TV show is not available.')) self.assertEqual(bot.sended_message['chat_id'], 1) self.assertEqual(type(bot.sended_message['reply_markup']), ReplyKeyboardHide) # trying to watch non-existent season upd.message.text = '/watch house of cards s5' watch(bot, upd) self.assertEqual(bot.sended_message['text'], _('This season is not available.')) self.assertEqual(bot.sended_message['chat_id'], 1) self.assertEqual(type(bot.sended_message['reply_markup']), ReplyKeyboardHide) # trying to watch unavailable season upd.message.text = '/watch house of cards s2 e1' watch(bot, upd) self.assertEqual(bot.sended_message['text'], _('This season is not available.')) self.assertEqual(bot.sended_message['chat_id'], 1) self.assertEqual(type(bot.sended_message['reply_markup']), ReplyKeyboardHide) # trying to watch non-existent episode upd.message.text = '/watch house of cards s1 e5' watch(bot, upd) self.assertEqual(bot.sended_message['text'], _('This episode is not available.')) self.assertEqual(bot.sended_message['chat_id'], 1) self.assertEqual(type(bot.sended_message['reply_markup']), ReplyKeyboardHide) # trying to watch unavailable episode upd.message.text = '/watch house of cards s1 e2' watch(bot, upd) self.assertEqual(bot.sended_message['text'], _('This episode is not available.')) self.assertEqual(bot.sended_message['chat_id'], 1) self.assertEqual(type(bot.sended_message['reply_markup']), ReplyKeyboardHide)
def __init__(self): self.mot_tracker = Sort() # create instance of the SORT tracker self.video = Video("../datasets/AICity_data/train/S03/c010/frames")
email="email", password="******", bio="Suzie's bio") c = User(username="******", email="eeemail", password="******", bio="Cheese's bio") j = User(username="******", email="email1", password="******", bio="Jasmine's bio") # #Videos v1 = Video(video_path="path string1", description="abcd", date_posted=datetime.now()) v2 = Video(video_path="pathstring2", description="efgh", date_posted=datetime.now()) v = [v1, v2] # Images i1 = Image(image_path="path string1", description="ABCD", date_posted=datetime.now(), user=s) i2 = Image(image_path="pathstring2", description="EFGH",