Example #1
0
 def test_add_vcategories(self):
     elearning = MyElearning()
     elearning.connect()
     elearning.read_vcategories()
     list_vcategories = elearning.list_vcategories
     init_size = len(list_vcategories)
     elearning.add_vcategory("python")
     self.assertFalse(init_size == len(list_vcategories))
Example #2
0
 def test_add_video(self):
     elearning = MyElearning()
     elearning.connect()
     elearning.read_videos()
     list_videos = elearning.list_videos
     init_size = len(list_videos)
     elearning.add_video(
         "Cours Python 3",
         "https://www.youtube.com/watch?v=HWxBtxPBCAc&list=PLrSOXFDHBtfHg8fWBd7sKPxEmahwyVBkC",
         3)
     list_videos = elearning.list_videos
     self.assertFalse(init_size == len(list_videos))
Example #3
0
 def test_find_videos(self):
     elearning = MyElearning()
     elearning.connect()
     critere_recherche = {"video_name": "cloud"}
     elearning.find_videos(critere_recherche)
     list_videos = elearning.list_videos
     self.assertIsNotNone(list_videos)
Example #4
0
 def test_get_vcategory_id(self):
     elearning = MyElearning()
     elearning.connect()
     vcategory_id = elearning.get_vcategory_id('cloud')
     self.assertTrue(vcategory_id)
Example #5
0
 def test_connect(self):
     elearning = MyElearning()
     elearning.connect()
     self.assertTrue(elearning.connection)
Example #6
0
 def test_read_vcategories(self):
     elearning = MyElearning()
     elearning.connect()
     elearning.read_vcategories()
     list_vcategories = elearning.list_vcategories
     self.assertIsNotNone(list_vcategories)
Example #7
0
 def test_get_video_id(self):
     elearning = MyElearning()
     elearning.connect()
     video_id = elearning.get_video_id(
         'https://www.youtube.com/channel/UC5cs06DgLFeyLIF_II7lWCQ')
     self.assertTrue(video_id)
Example #8
0
 def test_read_videos(self):
     elearning = MyElearning()
     elearning.connect()
     elearning.read_videos()
     list_videos = elearning.list_videos
     self.assertIsNotNone(list_videos)
Example #9
0
from elearning import MyElearning
from flask import Flask, request, render_template, jsonify
import logging
import json

logging.basicConfig(filename='logs.log', level=logging.DEBUG)

learning = MyElearning()
learning.set_logger()
learning.connect()

app = Flask(__name__)


@app.route('/', methods=['GET'])
def get_video():
    name = request.args.get("video")
    if name == None:
        learning.read_videos()
    else:
        learning.find_videos({"video_name": str(name)})
    a = learning.list_videos
    return render_template("index.html", video=a)


@app.route('/video/<video_id>', methods=['GET'])
def video_page(video_id):
    learning.find_videos({"video_id": int(video_id)})
    list_videos = learning.list_videos
    a = list_videos[0]
    learning.read_videos()