-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFWStackTemplateGenerator.py
More file actions
45 lines (28 loc) · 1.16 KB
/
FWStackTemplateGenerator.py
File metadata and controls
45 lines (28 loc) · 1.16 KB
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
import xml.etree.ElementTree as ET
import pymongo
from pymongo import MongoClient
filename = './static/templates/stackTemplate.xml'
def addVideo(videoObject):
tree = ET.ElementTree(file='./static/templates/stackTemplate.xml')
root = tree.getroot()
grids = root.iter('grid')
for grid in grids:
section = grid.find('section')
newlockup = lockupTemplate()
img = newlockup.find('img')
print (videoObject)
newlockup.set('videoIdentifier', videoObject['yt_id'])
img.set('src', videoObject['thunmbnail_url'])
dimensions = videoObject['dimensions']
img.set('width', "320")
img.set('height', "180")
title = newlockup.find('title')
title.text = videoObject['title']
section.append(newlockup)
with open(filename, 'w', encoding='utf-8') as file:
tree.write(file, xml_declaration=True, encoding='unicode')
ET.dump(tree)
return
def lockupTemplate():
lockup = ET.fromstring('<lockup videoIdentifier=""><img src="" width="" height="" /><title></title></lockup>')
return lockup