summaryrefslogtreecommitdiff
path: root/cli/commands/site/populate.py
blob: 4b5bb73c72e19130b952c23bad340c8422a925db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import click

# lines = """/static/media/last-museum/zohra-opoku/.mp4
# /static/media/last-museum/zohra-opoku/MVI_4388.mp4
# /static/media/last-museum/zohra-opoku/MVI_4390.mp4
# /static/media/last-museum/zohra-opoku/.mp4""".split("\n")

lines = [
"/static/media/last-museum/zohra-opoku/MVI_4367.mp4",
]

letters = ['a','b','c','d','e','f','g','h','i','j']

@click.command('populate')
@click.pass_context
def cli(ctx):
  """Populate video pages"""

  import requests 

  def post(endpoint, data):
    resp = requests.post(endpoint, json=data)
    return None if resp.status_code != 200 else resp.json()

  graph_id = 3
  name = "Zohra Opoku. Chapter 9: To Me Belongs Yesterday"
  index = 0

  for url in lines:
    slug = url.split("/")[5].replace(".mp4", "").lower()
    slug = "opoku-" + "9-to-me-belongs-yesterday" # + letters[index]
    print(slug)
    index += 1

    page_data = {
      "graph_id": graph_id,
      "path": slug,
      "title": name,
      "username": "jules",
      "description":"",
      "settings": {
        "x": 0.05,
        "y": 0.05,
        "background_color": "#000000",
        "background_audio_id": 0,
        "restart_audio": False
      }
    }
    page_res = post("http://0.0.0.0:5000/api/v1/page/", page_data)
    page_id = page_res['res']['id']

    tile_data = {
      "graph_id": graph_id, 
      "page_id": page_id,
      "target_page_id": None,
      "type": "video",
      "settings": {
        "x": 0,
        "y": 0,
        "width": 1920,
        "height": 1080,
        "rotation": 0,
        "scale": 1,
        "opacity": 1,
        "units": False,
        "align": "center_center",
        "has_audio": False,
        "audio_on_click_id": 0,
        "audio_on_hover_id": 0,
        "navigate_when_audio_finishes": False,
        "video_style": "cover",
        "url": url,
        "external_link_url": "",
        "cursor": "none",
        "muted": True,
        "loop": True,
        "autoadvance": False
      }
    }

    page_res = post("http://0.0.0.0:5000/api/v1/tile/", tile_data)