Skip to content
This repository has been archived by the owner on Jul 23, 2020. It is now read-only.

Commit

Permalink
11
Browse files Browse the repository at this point in the history
  • Loading branch information
lock committed May 11, 2019
1 parent 3fa106d commit 80134a0
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 31 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# 玩很大转播计划 配套程序


![计划图片](./计划.png)

本程序为计划中的"参与者电脑"服务

玩很大首播时间:每周六晚22点

开发语言:Python 3.7+
Expand Down
Binary file added icon.icns
Binary file not shown.
46 changes: 24 additions & 22 deletions layout_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from test_connect import test_connect



class Frame:
__m3u8_process = None
__server_process = None
Expand Down Expand Up @@ -194,8 +193,9 @@ def clear_cache(self):
messagebox.showerror('出现错误', '清空文件夹失败\n' + dir + '\n' + e.__str__())

def create_mp4(self):

if not utils.has_ffmpeg():
return messagebox.showerror('错误', '没有安装 FFmpeg')
return messagebox.showerror('错误', '没有安装 ffmpeg')

video_cache_dir = self.check_video_cache_dir()
if not video_cache_dir:
Expand All @@ -211,25 +211,27 @@ def create_mp4(self):
command_line = 'ffmpeg -f concat -safe 0 -i {} -c copy {} -y'.format(list_path, final_mp4_path)

if platform == 'win32':
process = subprocess.Popen(command_line, shell=True, creationflags=subprocess.CREATE_NEW_CONSOLE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return_code = process.wait()
if return_code == 0:
# 合并final.mp4成功,打开文件
if messagebox.askyesno('合并文件成功', '是否打开文件夹?'):
subprocess.Popen('explorer /select,"{}"'.format(final_mp4_path))

elif platform == 'darwin':
self.root.iconify()
messagebox.showinfo('开始合并视频')
si = subprocess.STARTUPINFO()
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
process = subprocess.Popen(command_line, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, startupinfo=si)
else:
process = subprocess.Popen(command_line, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
win = tkinter.Toplevel()
win.resizable(0, 0)
tkinter.Label(win, text='正在合并视频文件中,请稍候', font=('times', 20, 'bold')).pack(padx=10, pady=10)
win.after(100, utils.move_to_screen_center, win)
return_code = process.wait()
win.destroy()
self.root.deiconify()
if return_code == 0:
if msgbox.askyesno('合并文件成功', '是否打开文件夹?'):

win = tkinter.Toplevel()
tkinter.Label(win, text='正在合并视频文件中,请稍候', font=('times', 20, 'bold')).pack(padx=10, pady=10)
win.resizable(0, 0)
win.after(100, utils.move_to_screen_center, win)

return_code = process.wait()
win.destroy()

if return_code == 0:
if messagebox.askyesno('合并文件成功', '是否打开文件夹?'):
if platform == 'win32':
subprocess.Popen('explorer /select,"{}"'.format(final_mp4_path))
else:
subprocess.Popen(['open', '-R', final_mp4_path])
pass
else:
messagebox.showinfo('合并视频文件错误', process.stdout.read())
8 changes: 7 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import tkinter
from multiprocessing import freeze_support
from tkinter import messagebox
from sys import platform

import layout_button
import layout_local
Expand All @@ -24,7 +25,12 @@

root = tkinter.Tk()
root.title('综艺玩很大 转播程序 v0.5')
root.iconbitmap(resource_path.path('./icon.ico'))
# 设置windows窗口图标
if platform == 'win32':
icon = resource_path.path('icon.ico')
print('icon', icon)
root.iconbitmap(icon)

# 禁止改变窗口大小
root.resizable(False, False)

Expand Down
22 changes: 17 additions & 5 deletions main.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@

from sys import platform

block_cipher = None

datas = ['index.html', 'icon.ico', 'icon.icns']
if platform == 'win32':
path = 'E:\\'
icon = 'icon.ico'
else:
path = '/Users/lock/Desktop/hls_downloader/'
icon = 'icon.icns'

datas = [(path + item,'.') for item in datas]

print('datas', datas)

block_cipher = None


a = Analysis(['main.py'],
pathex=[path],
binaries=[],
datas=[(path + 'icon.ico','.'),(path + 'index.html','.')],
datas=datas,
hiddenimports=['engineio.async_drivers.sanic'],
hookspath=[],
runtime_hooks=[],
Expand All @@ -22,8 +29,10 @@ a = Analysis(['main.py'],
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)

pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)

exe = EXE(pyz,
a.scripts,
a.binaries,
Expand All @@ -32,9 +41,12 @@ exe = EXE(pyz,
[],
name='main',
debug=False,
icon=path+'icon.ico',
bootloader_ignore_signals=False,
strip=False,
upx=True,
runtime_tmpdir=None,
console=False )
console=False , icon=icon)
app = BUNDLE(exe,
name='main.app',
icon=icon,
bundle_identifier=None)
11 changes: 8 additions & 3 deletions utils.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import hashlib
import socket
from os import popen
import subprocess
from urllib.parse import urlparse

from requests import get


def has_ffmpeg() -> bool:
check_ffmpeg = popen('ffmpeg -version').read()
return 'ffmpeg version' in check_ffmpeg
p = subprocess.Popen('ffmpeg -version', shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
msg = ''
for line in p.stdout.readlines():
msg += line.decode()
p.wait()
return 'ffmpeg version' in msg


def is_url(_url: str) -> bool:
Expand Down
Binary file added 计划.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 80134a0

Please sign in to comment.