Skip to content

Commit

Permalink
updated "script_sentence_length" in config. Fixes #95 (#101)
Browse files Browse the repository at this point in the history
* Update to Cloudflare worker for image gen, updated G4F references to use 4o mini, and fixed Firefox profile handling to account for spaces in pathname (#94)

* Update G4F references & Firefox profile handling

* Refactor YouTube image generation to use account-specific worker URL and remove deprecated code; update Python version and .gitignore

* Added G4F image generation to replace deprecated hercai image gen; Replaced fixed venv location with automated detection in Tts.py

* Revert Twitter cron options back to default

* Switched G4F to first option during setup and added recommendation hint for new users to select the G4F option.

* Delete har_and_cookies/blackbox.json

* Add Link to X

* Ambrogio: Code improvements (#98)

Modified files:
- src/main.py
- src/cron.py
- src/constants.py
- src/classes/Outreach.py

Co-authored-by: appuser <appuser@localhost>

* updated variable "script_sentence_length" in config

* handled sentence length none exception

* refactored script length function call logic

---------

Co-authored-by: ThomsenDrake <[email protected]>
Co-authored-by: FujiwaraChoki <[email protected]>
Co-authored-by: Saro Antonello Lovito <[email protected]>
Co-authored-by: appuser <appuser@localhost>
  • Loading branch information
5 people authored Feb 19, 2025
1 parent a7ed495 commit 754aec4
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
[![GitHub stars](https://img.shields.io/github/stars/FujiwaraChoki/MoneyPrinterV2?style=for-the-badge)](https://github.com/FujiwaraChoki/MoneyPrinterV2/stargazers)
[![Discord](https://img.shields.io/discord/1134848537704804432?style=for-the-badge)](https://dsc.gg/fuji-community)

> Follow me on [X](https://x.com/DevBySami).
An Application that automates the process of making money online.
MPV2 (MoneyPrinter Version 2) is, as the name suggests, the second version of the MoneyPrinter project. It is a complete rewrite of the original project, with a focus on a wider range of features and a more modular architecture.

Expand Down
3 changes: 2 additions & 1 deletion config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
"outreach_message_body_file": "outreach_message.html",
"assembly_ai_api_key": "",
"font": "bold_font.ttf",
"imagemagick_path": "Path to magick.exe or on linux/macOS just /usr/bin/convert"
"imagemagick_path": "Path to magick.exe or on linux/macOS just /usr/bin/convert",
"script_sentence_length": 4
}
11 changes: 11 additions & 0 deletions src/classes/Outreach.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ def get_items_from_file(self, file_name: str) -> list:
return items

def set_email_for_website(self, index: int, website: str, output_file: str):
"""Extracts an email address from a website and updates a CSV file with it.
This method sends a GET request to the specified website, searches for the
first email address in the HTML content, and appends it to the specified
row in a CSV file. If no email address is found, no changes are made to
the CSV file.
Args:
index (int): The row index in the CSV file where the email should be appended.
website (str): The URL of the website to extract the email address from.
output_file (str): The path to the CSV file to update with the extracted email."""
# Extract and set an email for a website
email = ""

Expand Down
5 changes: 3 additions & 2 deletions src/classes/YouTube.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ def generate_script(self) -> str:
Returns:
script (str): The script of the video.
"""
sentence_length = get_script_sentence_length()
prompt = f"""
Generate a script for a video in 4 sentences, depending on the subject of the video.
Generate a script for a video in {sentence_length} sentences, depending on the subject of the video.
The script is to be returned as a string with the specified number of paragraphs.
Expand All @@ -169,7 +170,7 @@ def generate_script(self) -> str:
Obviously, the script should be related to the subject of the video.
YOU MUST NOT EXCEED THE 4 SENTENCES LIMIT. MAKE SURE THE 4 SENTENCES ARE SHORT.
YOU MUST NOT EXCEED THE {sentence_length} SENTENCES LIMIT. MAKE SURE THE {sentence_length} SENTENCES ARE SHORT.
YOU MUST NOT INCLUDE ANY TYPE OF MARKDOWN OR FORMATTING IN THE SCRIPT, NEVER USE A TITLE.
YOU MUST WRITE THE SCRIPT IN THE LANGUAGE SPECIFIED IN [LANGUAGE].
ONLY RETURN THE RAW CONTENT OF THE SCRIPT. DO NOT INCLUDE "VOICEOVER", "NARRATOR" OR SIMILAR INDICATORS OF WHAT SHOULD BE SPOKEN AT THE BEGINNING OF EACH PARAGRAPH OR LINE. YOU MUST NOT MENTION THE PROMPT, OR ANYTHING ABOUT THE SCRIPT ITSELF. ALSO, NEVER TALK ABOUT THE AMOUNT OF PARAGRAPHS OR LINES. JUST WRITE THE SCRIPT
Expand Down
15 changes: 15 additions & 0 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,18 @@ def get_imagemagick_path() -> str:
"""
with open(os.path.join(ROOT_DIR, "config.json"), "r") as file:
return json.load(file)["imagemagick_path"]

def get_script_sentence_length() -> int:
"""
Gets the forced script's sentence length.
In case there is no sentence length in config, returns 4 when none
Returns:
length (int): Length of script's sentence
"""
with open(os.path.join(ROOT_DIR, "config.json"), "r") as file:
config_json = json.load(file)
if (config_json.get("script_sentence_length") is not None):
return config_json["script_sentence_length"]
else:
return 4
9 changes: 9 additions & 0 deletions src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@
AMAZON_FEATURE_BULLETS_ID = "feature-bullets"

def parse_model(model_name: str) -> any:
"""Retrieve a model object based on the provided model name.
Args:
model_name (str): The name of the model to retrieve. Supported names are
"gpt4", "gpt35_turbo", "llama2_7b", "llama2_13b", "llama2_70b", and "mixtral_8x7b".
Returns:
any: The corresponding model object from the `g4f.models` module. If the
model name is not recognized, defaults to returning the "gpt35_turbo" model."""
if model_name == "gpt4":
return g4f.models.gpt_4
elif model_name == "gpt35_turbo":
Expand Down
17 changes: 17 additions & 0 deletions src/cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@
from classes.YouTube import YouTube

def main():
"""Main function to post content to Twitter or upload videos to YouTube.
This function determines its operation based on command-line arguments:
- If the purpose is "twitter", it initializes a Twitter account and posts a message.
- If the purpose is "youtube", it initializes a YouTube account, generates a video with TTS, and uploads it.
Command-line arguments:
sys.argv[1]: A string indicating the purpose, either "twitter" or "youtube".
sys.argv[2]: A string representing the account UUID.
The function also handles verbose output based on user settings and reports success or errors as appropriate.
Args:
None. The function uses command-line arguments accessed via sys.argv.
Returns:
None. The function performs operations based on the purpose and account UUID and does not return any value."""
purpose = str(sys.argv[1])
account_id = str(sys.argv[2])

Expand Down
41 changes: 41 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,27 @@
from classes.AFM import AffiliateMarketing

def main():
"""Main entry point for the application, providing a menu-driven interface
to manage YouTube, Twitter bots, Affiliate Marketing, and Outreach tasks.
This function allows users to:
1. Start the YouTube Shorts Automater to manage YouTube accounts,
generate and upload videos, and set up CRON jobs.
2. Start a Twitter Bot to manage Twitter accounts, post tweets, and
schedule posts using CRON jobs.
3. Manage Affiliate Marketing by creating pitches and sharing them via
Twitter accounts.
4. Initiate an Outreach process for engagement and promotion tasks.
5. Exit the application.
The function continuously prompts users for input, validates it, and
executes the selected option until the user chooses to quit.
Args:
None
Returns:
None"""

# Get user input
# user_input = int(question("Select an option: "))
Expand Down Expand Up @@ -166,6 +187,16 @@ def main():
command = f"python {cron_script_path} youtube {selected_account['id']}"

def job():
"""Executes a shell command using subprocess.run.
This function runs a specified shell command using the subprocess module.
The command to be executed should be defined in the 'command' variable.
Args:
None
Returns:
None"""
subprocess.run(command)

if user_input == 1:
Expand Down Expand Up @@ -274,6 +305,16 @@ def job():
command = f"python {cron_script_path} twitter {selected_account['id']}"

def job():
"""Executes a shell command using subprocess.run.
This function runs a specified shell command using the subprocess module.
The command to be executed should be defined in the 'command' variable.
Args:
None
Returns:
None"""
subprocess.run(command)

if user_input == 1:
Expand Down

0 comments on commit 754aec4

Please sign in to comment.