Skip to content

Commit

Permalink
新增007-CutVideoAudio视频剪辑、修复下载器bug
Browse files Browse the repository at this point in the history
  • Loading branch information
xhunmon committed Mar 19, 2022
1 parent e41e660 commit 5591e55
Show file tree
Hide file tree
Showing 23 changed files with 901 additions and 30 deletions.
4 changes: 2 additions & 2 deletions 001-Downloader/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
expired_time=2025/12/15 23:59:59

#app的版本名称
version_name=1.0.3
version_name=1.0.4

#app的版本号
version_code=103
version_code=1040
17 changes: 8 additions & 9 deletions 001-Downloader/douyin/dy_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def start(self, url, path):
# 读取保存路径
self.save = path
# 读取下载视频个数
self.count = 35
self.count = 10
# 读取下载是否下载音频
self.musicarg = True
# 读取用户主页地址
Expand Down Expand Up @@ -83,7 +83,7 @@ def parse_single(self):
aweme_id.append(str(detail['aweme_id']))
nickname.append(str(detail['author']['nickname']))
Downloader.print_ui('开始下载单个视频' + video_list[0])
self.videos_download(1, author_list, video_list, aweme_id, nickname, max_cursor)
self.videos_download(author_list, video_list, aweme_id, nickname, max_cursor)

# 匹配粘贴的url地址
def Find(self, string):
Expand Down Expand Up @@ -130,7 +130,6 @@ def get_data(self, api_post_url, max_cursor):
Downloader.print_ui('[ 用户 ]:' + str(self.nickname) + '\r')
max_cursor = html['max_cursor']
result = html['aweme_list']
self.count = len(result)
Downloader.print_ui('----抓获数据成功----\r')

# 处理第一页视频信息
Expand Down Expand Up @@ -167,14 +166,13 @@ def next_data(self, max_cursor):
index += 1
# Downloader.print_ui('----正在对' + max_cursor + '页进行第 %d 次尝试----\r' % index)
Downloader.print_ui('----正在对{}页进行第 {} 次尝试----\r'.format(max_cursor, index))
time.sleep(0.3)
time.sleep(3)
response = requests.get(url=api_naxt_post_url, headers=self.headers)
html = json.loads(response.content.decode())
if self.end == False:
# 下一页值
max_cursor = html['max_cursor']
result = html['aweme_list']
self.count = len(result)
Downloader.print_ui('----{}页抓获数据成功----\r'.format(max_cursor))
# 处理下一页视频信息
self.video_info(result, max_cursor)
Expand All @@ -200,7 +198,7 @@ def video_info(self, result, max_cursor):
# 封面大图
# dynamic_cover = []

for i2 in range(self.count):
for i2 in range(len(result)):
try:
author_list.append(str(result[i2]['desc']))
video_list.append(str(result[i2]['video']['play_addr']['url_list'][0]))
Expand All @@ -210,10 +208,11 @@ def video_info(self, result, max_cursor):
except Exception as error:
# Downloader.print_ui2(error)
pass
self.videos_download(self.count, author_list, video_list, aweme_id, nickname, max_cursor)
self.videos_download(author_list, video_list, aweme_id, nickname, max_cursor)
return self, author_list, video_list, aweme_id, nickname, max_cursor

def videos_download(self, count, author_list, video_list, aweme_id, nickname, max_cursor):
def videos_download(self, author_list, video_list, aweme_id, nickname, max_cursor):
count = len(author_list)
Downloader.add_total_count(count)
for i in range(count):
if count == 1:
Expand Down Expand Up @@ -290,7 +289,7 @@ def videos_download(self, count, author_list, video_list, aweme_id, nickname, ma
Downloader.add_success_count()
except Exception as error:
# Downloader.print_ui2(error)
Downloader.print_ui('该页视频没有' + str(self.count) + '个,已为您跳过\r')
Downloader.print_ui('该页视频没有' + str(count) + '个,已为您跳过\r')
Downloader.add_failed_count()
break
self.next_data(max_cursor)
14 changes: 4 additions & 10 deletions 005-PaidSource/v2ray_pool/_db-checked.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
ss://YWVzLTI1Ni1nY206ZzVNZUQ2RnQzQ1dsSklk@172.99.190.39:5003#github.com/freefq%20-%20%E7%BE%8E%E5%9B%BD%20%2010,172.99.190.39,美国 康涅狄格
ss://YWVzLTI1Ni1nY206ZTRGQ1dyZ3BramkzUVk@172.99.190.205:9101#github.com/freefq%20-%20%E7%BE%8E%E5%9B%BD%20%2015,172.99.190.205,美国 康涅狄格
ss://YWVzLTI1Ni1nY206ZmFCQW9ENTRrODdVSkc3QDE0NS4yMzkuMS4xMDA6MjM3NQ==#github.com%2Ffreefq+-+%E8%8B%B1%E5%9B%BD++18,145.239.1.100,德国 Hessen
ss://Y2hhY2hhMjAtaWV0Zi1wb2x5MTMwNTpzRjQzWHQyZ09OcWNnRlg1NjNAMTQxLjk1LjAuMjY6ODI2#github.com%2Ffreefq+-+%E8%8B%B1%E5%9B%BD++13,54.38.217.138,美国 新泽西
ss://YWVzLTI1Ni1nY206WTZSOXBBdHZ4eHptR0NAMTcyLjk5LjE5MC4xNDk6MzMwNg==#github.com%2Ffreefq+-+%E7%BE%8E%E5%9B%BD++14,172.99.190.149,美国 康涅狄格
ss://YWVzLTI1Ni1nY206ZmFCQW9ENTRrODdVSkc3QDE3Mi45OS4xOTAuMTg4OjIzNzY=#github.com%2Ffreefq+-+%E7%BE%8E%E5%9B%BD++11,172.99.190.188,美国 康涅狄格
ss://YWVzLTI1Ni1nY206UENubkg2U1FTbmZvUzI3QDEzNC4xOTUuMTk2LjE0Nzo4MDkw#github.com%2Ffreefq+-+%E5%8C%97%E7%BE%8E%E5%9C%B0%E5%8C%BA++9,134.195.196.147,美国
ss://YWVzLTI1Ni1nY206ekROVmVkUkZQUWV4Rzl2QDE2OS4xOTcuMTQxLjkxOjYzNzk=#github.com%2Ffreefq+-+%E5%8C%97%E7%BE%8E%E5%9C%B0%E5%8C%BA++22,169.197.141.91,美国 佐治亚 亚特兰大
ss://YWVzLTI1Ni1nY206ZmFCQW9ENTRrODdVSkc3QDEzNC4xOTUuMTk2LjE5MzoyMzc2#github.com%2Ffreefq+-+%E5%8C%97%E7%BE%8E%E5%9C%B0%E5%8C%BA++15,134.195.196.193,美国
ss://YWVzLTI1Ni1nY206ZzVNZUQ2RnQzQ1dsSklkQDEzNC4xOTUuMTk2LjIwMDo1MDAz#github.com%2Ffreefq+-+%E5%8C%97%E7%BE%8E%E5%9C%B0%E5%8C%BA++10,134.195.196.200,美国
ss://YWVzLTI1Ni1nY206cEtFVzhKUEJ5VFZUTHRN@134.195.196.68:443#github.com/freefq%20-%20%E5%8C%97%E7%BE%8E%E5%9C%B0%E5%8C%BA%20%202,134.195.196.68,美国
ss://YWVzLTI1Ni1nY206ZTRGQ1dyZ3BramkzUVk@134.195.196.81:9101#github.com/freefq%20-%20%E5%8C%97%E7%BE%8E%E5%9C%B0%E5%8C%BA%20%206,134.195.196.81,美国
ss://YWVzLTI1Ni1nY206WEtGS2wyclVMaklwNzQ@134.195.196.187:8009#github.com/freefq%20-%20%E5%8C%97%E7%BE%8E%E5%9C%B0%E5%8C%BA%20%201,134.195.196.187,美国
vmess://ew0KICAidiI6ICIyIiwNCiAgInBzIiA6Iue/u+WimeWFmmZhbnFpYW5nZGFuZy5jb20iLCIiIDogIkBTU1JTVUItVjE1LeS7mOi0ueaOqOiNkDpzdW8ueXQvc3Nyc3ViIiwNCiAgImFkZCI6ICI0Mi4xOTMuNDguNjQiLA0KICAicG9ydCI6ICI1MDAwMiIsDQogICJpZCI6ICI0MTgwNDhhZi1hMjkzLTRiOTktOWIwYy05OGNhMzU4MGRkMjQiLA0KICAiYWlkIjogIjY0IiwNCiAgInNjeSI6ICJhdXRvIiwNCiAgIm5ldCI6ICJ0Y3AiLA0KICAidHlwZSI6ICJub25lIiwNCiAgImhvc3QiOiAiNDIuMTkzLjQ4LjY0IiwNCiAgInBhdGgiOiAiIiwNCiAgInRscyI6ICIiLA0KICAic25pIjogIiINCn0=,42.193.48.64,中国 上海 上海市 电信
10 changes: 5 additions & 5 deletions 005-PaidSource/v2ray_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ def search_node():
Config.set_v2ray_core_path('/Users/Qincji/Desktop/develop/soft/intalled/v2ray-macos-64') # v2ray内核存放路径
Config.set_v2ray_node_path(
'/Users/Qincji/Desktop/develop/py/project/PythonIsTools/005-PaidSource/v2ray_pool') # 保存获取到节点的路径
proxy_url = 'ss://YWVzLTI1Ni1nY206UENubkg2U1FTbmZvUzI3@145.239.1.137:8091#github.com/freefq%20-%20%E8%8B%B1%E5%9B%BD%20%207'
proxy_url = 'ss://YWVzLTI1Ni1nY206WTZSOXBBdHZ4eHptR0M@134.195.196.3:3306#github.com/freefq%20-%20%E5%8C%97%E7%BE%8E%E5%9C%B0%E5%8C%BA%20%201'
dbm = DBManage()
dbm.init() # 必须初始化
# if dbm.check_url_single(proxy_url):
# urls = dbm.load_urls_by_net(proxy_url=proxy_url)
# dbm.check_and_save(urls, append=False)
dbm.load_urls_and_save_auto()
if dbm.check_url_single(proxy_url):
urls = dbm.load_urls_by_net(proxy_url=proxy_url)
dbm.check_and_save(urls, append=False)
# dbm.load_urls_and_save_auto()
# urls = dbm.load_unchecked_urls_by_local()
# dbm.check_and_save(urls, append=False)
utils.kill_all_v2ray()
Expand Down
4 changes: 2 additions & 2 deletions 006-TikTok/tikstar.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def parse_tags(page):


if __name__ == '__main__':
html = futil.read('source/tags.html')
html = futil.read('tags.html')
result = parse_tags(html)
print(result)
futil.write_json(result, 'source/handmade.json')
futil.write_json(result, 'shoes.json')
7 changes: 5 additions & 2 deletions 006-TikTok/tt_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
import time
from datetime import datetime

import file_util as futil

import uiautomator2 as u2

'''
https://github.com/openatx/uiautomator2
运行pip3 install -U uiautomator2 安装uiautomator2
运行python3 -m uiautomator2 init安装包含httprpc服务的apk到安卓手机
uiautomator2操作:https://python.iitter.com/other/35522.html
借助:weditor 来获取元素
借助:weditor 来获取元素,双击找控件id
(注意电脑要把代理关掉)
'''

Expand Down Expand Up @@ -197,5 +199,6 @@ def print_t(content):
if __name__ == "__main__":
# start_vpn()
# review_tiktok()
review_forYou()
# review_forYou()
# comment('Look at my')
d(resourceId="com.zhiliaoapp.musically:id/afa").click()
128 changes: 128 additions & 0 deletions 007-CutVideoAudio/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
9 changes: 9 additions & 0 deletions 007-CutVideoAudio/007-CutVideoAudio.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
41 changes: 41 additions & 0 deletions 007-CutVideoAudio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# FFmpeg批量剪切音视频

本项目主要通过ffmpeg工具进行批量视频剪辑,随机剪辑,从而躲过自媒体平台的检查,从而达到一份视频多个账号运营。

使用前提:**必须要安装ffmpeg程序**,安装过程请自行百度。


下载地址:

MacOS:[QincjiCut1.0.0-mac](https://github.com/xhunmon/PythonIsTools/releases/download/v1.0.4/QincjiCut1.0.0.app.zip) 下载后解压后使用

Window:QincjiCut1.0.0-mac (未打包)

效果如图:

![剪辑器截图](./doc/example.png)

#主要知识点

## python GUI(界面)

本文使用tkinter GUI(界面)框架进行界面显示:[./ui.py](ui.py)[学习参考](https://www.cnblogs.com/shwee/p/9427975.html)

## [pyinstaller](https://pyinstaller.readthedocs.io/en/stable/) 打包

使用pyinstaller把python程序打包成window和mac可执行文件,主要命令如下:
```shell
#① :生成xxx.spec文件;(去掉命令窗口-w)
pyinstaller -F -i res/logo.ico main.py -w
#②:修改xxx.spec,参考main.spec
#③:再次进行打包,参考installer-mac.sh
pyinstaller -F -i res/logo.ico main.spec -w
```
打包脚本与配置已放在 `doc` 目录下,需要拷贝出根目录进行打包。

注意:
pyinstaller打包工具的版本与python版本、python所需第三方库以及操作系统会存在各种问题,所以需要看日志查找问题。例如:打包后运用,发现导入pyppeteer报错,通过降低版本后能正常使用:pip install pyppeteer==0.2.2

## 项目
本项目跟Downloader下载器基本相同,而ffmpeg命令则可以通过 [](https://qincji.gitee.io/2021/01/18/ffmpeg/18_command/)

Empty file added 007-CutVideoAudio/__init__.py
Empty file.
10 changes: 10 additions & 0 deletions 007-CutVideoAudio/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 常用配置模块
[common]
#软件使用截止日期
expired_time=2025/12/15 23:59:59

#app的版本名称
version_name=1.0.0

#app的版本号
version_code=1000
Binary file added 007-CutVideoAudio/doc/example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions 007-CutVideoAudio/doc/mac-sh/main.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- mode: python ; coding: utf-8 -*-


block_cipher = None


a = Analysis(['main.py','type_enum.py','ui.py','utils.py','editors.py','ff_util.py','ff_cut.py'],
pathex=['.'],
binaries=[],
datas=[('res/logo.ico', 'images'),('config.ini', '.')],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
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,
a.zipfiles,
a.datas,
[],
name='main',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None , icon='res/logo.ico')
app = BUNDLE(exe,
name='QincjiCut.app',
icon='res/logo.ico',
bundle_identifier=None)
Loading

0 comments on commit 5591e55

Please sign in to comment.