1 Star 2 Fork 2

极客柒/Video2Playable

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.py 1.97 KB
一键复制 编辑 原始数据 按行查看 历史
hw_Geek7 提交于 2021-11-24 20:14 . video convert to playable ver1.0.
# -*- coding: UTF-8 -*-
from IUtils import *
from IPlatform import *
import re
import time
def Convert():
try:
template = IUtils.fromFile("template/index.html")
config = IUtils.fromJsonAsDict("template/config.json")
#video resource
portrait = IUtils.fromFile2Base64("videos/portrait.mp4")
landscape = IUtils.fromFile2Base64("videos/landscape.mp4")
videoRes = f'''
window.videos = [null, null];
window.videos[0] = "data:video/mp4;base64,{portrait}";
window.videos[1] = "data:video/mp4;base64,{landscape}";
'''
#init channel. example applovin !
playableSDK = '''
window.playableSDK = {};
window.playableSDK.init=function()
{
window.playableSDK.storeUrl=(/android/i.test(navigator.userAgent))?window.androidStoreUrl:window.iosStoreUrl;
window.playableSDK.install=function(){
window.mraid&&window.mraid.open(window.playableSDK.storeUrl);
}
}
'''
initContet = f'''
<script type="text/javascript">
window.androidStoreUrl="{config['androidUrl']}";
window.iosStoreUrl="{config['iosUrl']}";
{playableSDK}
{videoRes}
</script>
'''
#install event
installEvent = '''
window.playableSDK.install();
'''
template = re.sub( r"__initEvent",initContet,template,1 )
template = re.sub( r"__installEvent",installEvent,template,1 )
IUtils.writeInFile( "out/index.html", template )
except Exception as e:
print(e)
Debug.LogExcept()
if __name__ == "__main__":
s = time.time()
print(f'Start : { time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) }')
Convert()
Debug.Export()
print(f'End : { time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) }')
print(f'Cost : { time.time() - s }')
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
HTML
1
https://gitee.com/welcome2jcSpace/video2playable.git
git@gitee.com:welcome2jcSpace/video2playable.git
welcome2jcSpace
video2playable
Video2Playable
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385