Adding Single Movies to Homepage

#controllers/home.py
import config, copy, lib
from flask import render_template, redirect
from models.moviedb import Moviedb

class Home():
  def __init__(self):
    self.lib = lib.Lib()
    self.moviedb = Moviedb()

  def get_youtube(self):
    self.vdict = copy.deepcopy(config.vdict)
    self.get_movie()
    return render_template('index.html', data=self.vdict)

  def get_movie(self, type=None):
    self.vdict['movies'] = self.moviedb.select(self.vdict['home_max_movie'])
    self.vdict['thumbs'] = self.lib.get_thumbs(self.vdict['movies'], 5, type='movie')
<!--templates/index.html-->
{% extends "base.html" %}

{% block head %}
{{ super() }}
<link href="/static/styles/index.css" rel="stylesheet" >
<link href="/static/styles/movie.css" rel="stylesheet" >
<script src="/static/scripts/index.js"></script>
<script src="/static/scripts/movie.js"></script>
{% endblock %}

{% block channel %}
<div class="channel region">
  <div class="channel-outer">
    <iframe  src="https://www.youtube.com/embed/videoseries?list=UUHwYHdX37UUt6d9e1wAp9Bw" 
      frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
    </iframe>
  </div>

  <div class="channel-outer">
    <iframe  src="https://www.youtube.com/embed/videoseries?list=UUC3kuksIZZQO6kVQlApEW1w" 
      frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
    </iframe>
  </div>

  <div class="channel-outer">
    <iframe  src="https://www.youtube.com/embed/videoseries?list=UUd3Jmi0SGGG-NvcEOge6bxw" 
      frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
    </iframe>
  </div>

  <div class="channel-outer">
    <iframe  src="https://www.youtube.com/embed/videoseries?list=UUGCeeEq-6y85svJ1atW5Bvw" 
      frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
    </iframe>
  </div>

  <a href="#"><img src="/static/images/horizontal-ad.png" /></a> 
  <a href="#"><img src="/static/images/horizontal-ad.png" /></a>
</div>
{% endblock %}

{% block content %}

<div id="video-wrapper" style="width:100%;"></div>
<script>movie.setVideo(`{{ data['movies'][0][1] }}`, `{{ data['movies'][0][2] }}`);</script> 

<div id='random-movies'>
  {% for v in range(1, data['movies']|length) %}
  <div class="movie-wrapper">
    <a href="/movie/{{ data['movies'][v][0] }}"><img src="{{ data['thumbs'][v] }}" /></a>
    <a class="movie-title" href="/movie/{{ data['movies'][v][0] }}">{{ data['movies'][v][3] }}</a>
  </div>
  {% endfor %}
</div>
{% endblock %}
//static/scripts/movie.js
class Movie{
  setVideo(videoId, vidType){
    
    if(vidType === "YouTube"){
      var src = "https://www.youtube.com/embed/" + videoId;
    }else if(vidType === "Facebook"){
      var src = `https://www.facebook.com/watch/?v=${videoId}`;
    }else if(vidType === "Dailymotion"){
      var src = "https://www.dailymotion.com/embed/video/" + videoId;
    }else if(vidType === "Vimeo"){
      var src = "https://player.vimeo.com/video/" + videoId;
    }else if(vidType === "OKRU"){
      var src = "//ok.ru/videoembed/" + videoId;
    }else if(vidType === "YouTubePl"){
      var src = "https://www.youtube.com/embed/videoseries?list=" + videoId;
    }

    if(vidType !== 'Facebook'){
      var iframe = `<div style='position:relative;padding-top:56.25%;margin-top:20px;'>
      <iframe id="video-player" src="${src}" frameborder="0" allowfullscreen></iframe>
      </div>`;
    }else{
      var iframe = `<div class="fb-video" data-href="${src}" data-width="auto" data-show-captions="true"></div>`;
    }

    $('#video-wrapper').html(iframe);
  }
}//End of class

const movie = new Movie();

GitHub: "https://github.com/Sokhavuth/ETV
Heroku: https://khmerweb-etv.herokuapp.com/

Comments

Popular posts from this blog