Skip to content

Commit 11a0ce8

Browse files
committed
ui
1 parent 2b645f9 commit 11a0ce8

File tree

12 files changed

+269
-20
lines changed

12 files changed

+269
-20
lines changed

.DS_Store

0 Bytes
Binary file not shown.

ProjectConfig/Script/API/YoutubeDownload.py

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,99 @@
3535

3636
from Common.Platform import Platform
3737

38+
39+
from Common.WebDriver.WebDriverCmd import CmdType
40+
from Common.WebDriver.WebDriverCmd import WebDriverCmd
41+
from Common.WebDriver.WebDriverCmd import CmdInfo
42+
43+
3844
# https://www.jianshu.com/p/e18cdb1053d0
3945
# pip3 install pytube
46+
# pytube http://youtu.be/rJ18V_NNq8g
4047

4148
from pytube import YouTube
4249

50+
from selenium.webdriver.common.by import By
51+
from selenium.webdriver.chrome.options import Options
52+
from selenium.webdriver.common.keys import Keys
53+
from selenium.webdriver import ActionChains
54+
from selenium import webdriver
55+
# urllib.error.URLError: <urlopen error [Errno 61] Connection refused>
4356

4457
# Youtube视频下载网站 https://zh.savefrom.net/7/
4558
class YoutubeDownload():
46-
59+
driver: None
60+
URL_HEAD = "http://47.242.56.146"
61+
URL_PORT = "5000"
4762

63+
4864
#构造函数
4965
def __init__(self):
50-
name =""
51-
66+
name =""
67+
self.Init()
68+
69+
def Init(self):
70+
# 创建chrome浏览器驱动,无头模式(超爽)
71+
chrome_options = Options()
72+
# chrome_options.add_argument('--headless')
73+
74+
self.driver = webdriver.Chrome(chrome_options=chrome_options)
75+
# 全屏
76+
self.driver.maximize_window()
77+
# 具体大小
78+
# driver.set_window_size(width, height)
79+
80+
# # 快照显示已经成功登录
81+
# print(driver.save_screenshot('jietu.png'))
82+
# driver.quit()
83+
5284
# pytube http://youtu.be/rJ18V_NNq8g --itag=22
5385

5486
# http://youtu.be/rJ18V_NNq8g
55-
def Download(self, url):
87+
def Download(self, url,savefilepath):
5688
print("YoutubeDownload Download url=",url)
57-
url = "http://youtu.be/rJ18V_NNq8g"
89+
# url = "http://youtu.be/rJ18V_NNq8g"
5890
# YouTube(url).streams.first().download()
91+
# self.DownloadByBrowser(url)
92+
self.DownloadServer(url,savefilepath)
93+
94+
95+
def DownloadServer(self, url,savefilepath):
96+
# http://47.242.56.146:5000/YoutubDownload?keyid=rJ18V_NNq8g
97+
idx = url.rfind("/")
98+
idx=idx+1
99+
keyid = url[idx:]
100+
url_server = self.URL_HEAD+":"+self.URL_PORT+"/YoutubDownload?keyid="+keyid
101+
print("YoutubeDownload url_server=",url_server)
102+
name = self.GetUrl(url_server)
103+
url_video = self.URL_HEAD+"/"+name
104+
print("YoutubeDownload url_video=",url_video)
105+
106+
r = requests.get(url_video)
107+
with open(savefilepath, "wb") as code:
108+
code.write(r.content)
109+
110+
111+
112+
def GetUrl(self, url):
113+
r = requests.get(url)
114+
return r.content.decode('utf-8',"ignore")
115+
116+
# Youtube视频下载网站 https://zh.savefrom.net/7/
117+
def DownloadByBrowser(self, url,savefilepath):
118+
# 加载百度页面
119+
self.driver.get("https://zh.savefrom.net/7/")
120+
time.sleep(1)
121+
webcmd = WebDriverCmd(self.driver)
122+
123+
key = "//input[@id='sf_url']"
124+
webcmd.AddCmdWait(CmdType.INPUT,key,url)
125+
# <input type="text" name="sf_url" value="" autofocus="" placeholder="在这里粘贴视频链接" onfocus="if(this.value &amp;&amp; this.select){this.select()}" id="sf_url">
126+
# <button type="submit" name="sf_submit" class="submit" id="sf_submit">下载</button>
127+
key = "//button[@id='sf_submit']"
128+
webcmd.AddCmd(CmdType.CLICK,key)
129+
webcmd.Run(True)
59130

60-
61131

62132
mainYoutubeDownload = YoutubeDownload()
63133

7 Bytes
Binary file not shown.

ProjectConfig/Script/Project/Resource.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,10 @@ def GetDirProduct(self):
187187
def GetDirProductCommon(self):
188188
return self.GetDirProduct()+"/Common"
189189

190-
190+
# go语言目录
191+
def GetDirGoRoot(self):
192+
return self.GetDirProductCommon()+"/GoUnity"
193+
191194
def GameResApp(self):
192195
dir = mainResource.GetResourceDataApp()+"/GameRes"
193196
if os.path.exists(dir) ==False:

ProjectConfig/Script/SellMyApp/SellMyApp.py

Lines changed: 79 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,27 @@ def GoApp(self,isHD):
120120
if cl == "youtube-link":
121121
pic =li.get_attribute('data-src')
122122
url = pic[2:]
123-
print("video = ",url)
124-
mainYoutubeDownload.Download(url)
123+
print("video = ",url)
124+
self.DeleteAllDownloadFile(downloadDir,".mp4")
125+
126+
127+
video_dst = self.GetAdHomeDir(isHD)+"/video.mp4"
128+
mainYoutubeDownload.Download(url,video_dst)
129+
130+
# video_download = ""
131+
# # 等待mp4下载完成
132+
# while True:
133+
# video_download = self.GetDownloadFile(downloadDir,".mp4")
134+
# time.sleep(1)
135+
# print ("waiting for download video mp4")
136+
# if len(video_download)>1:
137+
# break
138+
139+
# # copy
140+
141+
# FileUtil.CreateDir2(video_dst)
142+
# FileUtil.CopyFile(video_download,video_dst)
143+
125144
else:
126145
pic =li.get_attribute('data-src')
127146
print(pic)
@@ -268,6 +287,53 @@ def GetDecodeApkOutputDir(self,isHD):
268287

269288
return dirapk+"/ApkDecodeOutput"
270289

290+
291+
def ResizeImage(self):
292+
filesrc = self.GetAdHomeDir(isHD)+"/adhome.png"
293+
294+
w = 1920
295+
h = 1080
296+
filedst = self.GetAdHomeDir(isHD)+"/adhome_"+str(w)+"_"+str(h)+".png"
297+
self.ConverImage(filesrc,filedst,w,h)
298+
299+
w = 1024
300+
h = 500
301+
filedst = self.GetAdHomeDir(isHD)+"/adhome_"+str(w)+"_"+str(h)+".png"
302+
self.ConverImage(filesrc,filedst,w,h)
303+
304+
w = 1080
305+
h = 480
306+
filedst = self.GetAdHomeDir(isHD)+"/adhome_"+str(w)+"_"+str(h)+".png"
307+
self.ConverImage(filesrc,filedst,w,h)
308+
309+
w = 1256
310+
h = 706
311+
filedst = self.GetAdHomeDir(isHD)+"/video_taptap"+".png"
312+
self.ConverImage(filesrc,filedst,w,h)
313+
314+
# icon
315+
output = self.GetDecodeApkOutputDir(isHD)
316+
filesrc = output+"/res/mipmap-xxxhdpi/app_icon.png"
317+
318+
w = 512
319+
h = 512
320+
filedst = self.GetAdHomeDir(isHD)+"/icon_512.png"
321+
self.ConverImage(filesrc,filedst,w,h)
322+
323+
w = 1024
324+
h = 1024
325+
filedst = self.GetResourceDataIcon(isHD)+"/icon.jpg"
326+
self.ConverImage(filesrc,filedst,w,h)
327+
328+
FileUtil.RemoveFile(filesrc)
329+
330+
331+
332+
333+
def ConverImage(self,filesrc,filedst,width,height):
334+
filego = mainResource.GetDirGoRoot()+ "/Image/ImageConvert.go"
335+
os.system("go run "+filego+" "+filesrc+" "+filedst+" "+str(width)+" "+str(height))
336+
271337
def DownloadApkFinish(self,isHD):
272338
downloadDir = self.GetSystemDownloadDir()
273339
apk_download = self.GetDownloadFile(downloadDir,".apk")
@@ -298,8 +364,7 @@ def DecodeApk(self,isHD):
298364
apk = self.GetDownloadApkPath(isHD)
299365
output = self.GetDecodeApkOutputDir(isHD)
300366
mainApkTool.DecodeApK(apk,output)
301-
302-
367+
303368
# versionCode: '1'
304369
# versionName: '0.1'
305370
apktool_yml = output+"/apktool.yml"
@@ -367,13 +432,8 @@ def DecodeApk(self,isHD):
367432
name_decode = Common.GetMidString(strfile,head,end)
368433
strfile = strfile.replace(head+name_decode+end,head+name+end)
369434
FileUtil.SaveString2File(strfile,xml)
370-
371-
372-
# icon
373-
icon = output+"/res/mipmap-xxxhdpi/app_icon.png"
374-
dst_icon = self.GetAdHomeDir(isHD)+"/app_icon.png"
375-
FileUtil.CreateDir2(dst_icon)
376-
FileUtil.CopyFile(icon,dst_icon)
435+
436+
self.ResizeImage()
377437

378438
def GetBuildConfig_smali(self,isHD,package):
379439
output = self.GetDecodeApkOutputDir(isHD)+"/smali"
@@ -412,7 +472,14 @@ def ScansmaliFiles(self,sourceDir,package,outFilepath):
412472
self.ScansmaliFiles(sourceFile,package,outFilepath)
413473

414474
def GetAdHomeDir(self,isHD):
415-
ret = mainResource.GetProjectOutPutApp()+"/adhome"
475+
ret = mainResource.GetProjectOutPutApp()+"/adhome_sellmyapp"
476+
FileUtil.CreateDir2(ret)
477+
return ret
478+
479+
def GetResourceDataIcon(self,isHD):
480+
ret = mainResource.GetResourceDataApp()+"/icon"
481+
if isHD:
482+
ret = mainResource.GetResourceDataApp()+"/iconhd"
416483
FileUtil.CreateDir2(ret)
417484
return ret
418485

3.86 KB
Loading

ServerApp/.DS_Store

0 Bytes
Binary file not shown.

ServerApp/ServerLaunch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# 命令后面加 & 后台执行多个sh
33
sh /var/www/html/PythonUnity/ServerApp/AppleJWTToken.sh &
44
sh /var/www/html/PythonUnity/ServerApp/AppVersion.sh &
5-
5+
sh /var/www/html/PythonUnity/ServerApp/YoutubDownload.sh &
66

77
# vnc
88
# vncserver -kill :1

ServerApp/YoutubDownload.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
4+
cd /var/www/html/PythonUnity/ServerApp/YoutubDownload
5+
python3 YoutubDownload.py
6+

ServerApp/YoutubDownload/.DS_Store

6 KB
Binary file not shown.

0 commit comments

Comments
 (0)