Skip to content

Commit

Permalink
fix pyinstaller
Browse files Browse the repository at this point in the history
Lovi-0 committed Mar 20, 2024
1 parent 5e119df commit 56e8a45
Showing 10 changed files with 55 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -9,4 +9,5 @@ pyvenv.cfg
# Project specific
videos/
tmp/
debug.log
debug.log
run.exe
6 changes: 2 additions & 4 deletions Src/Lib/FFmpeg/my_m3u8.py
Original file line number Diff line number Diff line change
@@ -303,9 +303,7 @@ def timer(self, progress_counter, quit_event, timeout_checker):
def join(self, output_filename):
"""Join all segments file to a mp4 file name"""

current_dir = os.path.dirname(os.path.realpath(__file__))
file_list_path = os.path.join(current_dir, 'file_list.txt')

file_list_path = os.path.join('file_list.txt')
ts_files = [f for f in os.listdir(self.temp_folder) if f.endswith(".ts")]

def extract_number(file_name):
@@ -318,7 +316,7 @@ def extract_number(file_name):

with open(file_list_path, 'w') as f:
for ts_file in ts_files:
relative_path = os.path.relpath(os.path.join(self.temp_folder, ts_file), current_dir)
relative_path = os.path.relpath(os.path.join(self.temp_folder, ts_file))
f.write(f"file '{relative_path}'\n")

console.log("[cyan]Joining all files...")
2 changes: 1 addition & 1 deletion Src/Upload/__version__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__title__ = 'Streaming_community'
__version__ = 'v0.9.1'
__version__ = 'v0.9.2'
__author__ = 'Ghost6446'
__description__ = 'A command-line program to download film'
__license__ = 'MIT License'
1 change: 0 additions & 1 deletion Src/Upload/update.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@
repo_name = "StreamingCommunity_api"
repo_user = "ghost6446"
main = os.path.abspath(os.path.dirname(__file__))
base = "\\".join(main.split("\\")[:-1])

def get_install_version():
about = {}
5 changes: 2 additions & 3 deletions Src/Util/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
from pathlib import Path
import json, os

class ConfigManager:
def __init__(self, file_path):
@@ -18,6 +17,6 @@ def update_config(self, key, new_value):


# Example usage:
config_path = Path(__file__).parent.parent.parent / 'config.json'
config_path = os.path.join('config.json')
config_manager = ConfigManager(config_path)
config = config_manager.load_config()
12 changes: 5 additions & 7 deletions Src/Util/headers.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# 3.12.23 -> 10.12.23

# Import
from random_user_agent.user_agent import UserAgent
from random_user_agent.params import SoftwareName, OperatingSystem
import fake_useragent

# Variable
useragent = fake_useragent.UserAgent(use_external_data=True)

def get_headers():
software_names = [SoftwareName.CHROME.value]
operating_systems = [OperatingSystem.WINDOWS.value, OperatingSystem.LINUX.value]
user_agent_rotator = UserAgent(software_names=software_names, operating_systems=operating_systems, limit=10)

return user_agent_rotator.get_random_user_agent()
return useragent.firefox
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ bs4
lxml
tqdm
rich
random-user-agent
fake-useragent==1.1.3
ffmpeg-python
cryptography==3.4.8 # Problem with new version
m3u8
2 changes: 2 additions & 0 deletions run.py
Original file line number Diff line number Diff line change
@@ -115,6 +115,8 @@ def main():

if __name__ == '__main__':

main()

while 1:
cmd_insert = input("Quit the script [yes/no]: ")

37 changes: 37 additions & 0 deletions run.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- mode: python ; coding: utf-8 -*-


a = Analysis(
['run.py'],
pathex=[],
binaries=[],
datas=[('./Src/upload/__version__.py', 'Src/upload')],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
)
pyz = PYZ(a.pure)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='run',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
4 changes: 3 additions & 1 deletion update.py
Original file line number Diff line number Diff line change
@@ -140,4 +140,6 @@ def main_upload() -> None:
)
download_and_extract_latest_commit(repository_owner, repository_name, ["config.json"])

main_upload()
main_upload()

# pyinstaller --onefile --add-data "./Src/upload/__version__.py;Src/upload" run.py

0 comments on commit 56e8a45

Please sign in to comment.