# Automated Video and Podcast Uploading to Multiple Sites using Autohotkey, Selenium, and Platform APIs

![Alt text](Assets/Screenshots/MainScreen_v341.png "Screenshot of Main and Results Window")

# Supported Platforms
| Platform | Upload Type | 
|--|--|--|
| Locals | Video Upload w/Selenium |
| Bitchute | Video Upload w/Selenium |
| Rumble | Video Upload w/Selenium |
| DailyMotion | Video Upload w/Selenium |
| Brighteon | Video Upload w/Selenium |
| Odysee | Video + Audio Upload w/LBRY API |
| FDRPodcasts | Podcast w/Selenium |
| Discord | Announcement w/API | 
| Telegram | Announcement w/API |

## Other Features
- Install Uploader Updates from Gitea automatically
- Install Chrome Updates from chromium.org automatically 
- Schedule Posts for a later date & time
- Log Errors to a Discord Channel using webhook
- Discord Ping on Upload Completion
- Setting to confirm an upload before it's published
- Setting to show Tooltip progress at top of the screen showing current action being executed

# Installation
1.  Install .Net Framework 3.5 
	- Option 1: Click on Start Menu > Turn Windows Features On or Off > check the checkbox next to “.NET Framework 3.5” > Click OK
	- Option 2: Open up PowerShell as Administrator and run the command: `Enable-WindowsOptionalFeature -Online -FeatureName "NetFx3" -All`
2. 	Install [SeleniumBasic](https://github.com/florentbr/SeleniumBasic/releases/tag/v2.0.9.0) to control Chrome
	- Make sure to “Run as Administrator” on the file when installing so that it gets installed to `C:\Program Files\SeleniumBasic`. Otherwise it will get installed to `\AppData\` and the Poster will not be able to connect to Selenium and to Chrome.
3.	[Download latest ChromeDriver](https://chromedriver.chromium.org/downloads) for your Chrome version so Selenium can connect to Chrome for automation
	- Open Chrome and type in `about::version` into the URL bar. The very first line will tell you what Chrome version you have
	- After downloading, extract “chromedriver_win32.zip” and move the extracted chromedriver.exe to: `C:\Program Files\SeleniumBasic\chromedriver.exe`
	- NOTE: The chromedriver will need to be re-downloaded whenever Chrome updates to keep up with API changes
4. Install the [LBRY Desktop Application Manually](https://lbry.com/) or through chocolatey `choco install -y lbry`
	- Once installed log into your account, and also add your LBRY Channel ID to the settings.ini file
5.	[Download the latest .exe of the Uploader](https://freedomain.dev/yuriy/video-uploader/releases)
	- When run, the Uploader will automatically create the folders and files it requires in the same directory it's run from.

# Using Portable Version of Chrome
Using Selenium with a portable `Chrome for Testing` version of Chrome is the preferred way of uploading as it gives you full control over chrome and chromedriver updates and when to install them.
-  When running the uploader for the first time, you will be notified that `Chrome for Testing` was not found and that you can download it by clicking the `Chrome Up to Date` button. This will automatically get the latest version of Chrome and download + extract it to the the `\lib\` folder. It will also download the appropriate `chromedriver.exe` file for that version and prompt you for admin permission to move it to `C:\Program Files\SeleniumBasic\chromedriver.exe`.

# Windows Defender False Positive
Windows Defender will sometimes flag the compiled .exe version as a false positive. The easiest way to get around this is to whitelist the directory the folder where you're keeping the Uploader files in. To do this, open up `Windows Powershell` as Administrator and run the following command: `Add-MpPreference -ExclusionPath "PATHTOTHEFOLDER"`, eg: `Add-MpPreference -ExclusionPath "C:\Users\yuriy\Downloads\VideoUploader"`

# Settings File 
The Uploader reads & saves its settings to a `settings.ini` file, All customization, including custom profile URLs are stored here.   
On first run, if this file does not exist it will be automatically downloaded from the git repo.
Before running for the first time you should set the following settings in the file:
````
[General]
RootDirToStartIn= Parent Folder with your Video Projects
ShowTooltipProgress=1
DiscordWebhookBotURL=
DiscordVideosWebhookURL=
DiscordErrorLoggingWebhookBotURL=
DiscordUsernameID=
LBRYNewVideoStakeAmount=1.0
LBRYNetFilepath=C:\Program Files\LBRY\resources\static\daemon\lbrynet.exe
LBRYChannelID=
DailyMotionPostPageURL=
LocalsPostPageURL=
````
- [How to create Discord webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks)
- [How to get Telegram bot token + chat-id](https://tutorial.cytron.io/2021/09/01/how-to-create-a-telegram-bot-get-the-api-key-and-chat-id/)
- All other settings will automatically get written to the `settings.ini` file as you check/uncheck the setting boxes while running the Poster.

# Project Files
When you start the Uploader, it will ask you to select a project folder that contains the files that will be used for the upload. <br>
The program will then loop through that project folder and look for the following files and automatically select them.<br>
You can select a different file in the main window if the auto selection does not select the correct file.<br>
`title.txt` which should contain the Title of your video/podcast<br>
`body.txt` which should contain the body text of your video/podcast<br>
`keywords.txt` which contains the tags/keywords that will be used in the video uploads<br>
`keywords_podcast.txt` (Optional) which contains the tags/keywords that will be used in the podcast upload. `keywords.txt` will be used for podcast tags if this does not exist.<br>
`*.mp4` an mp4 file which is the video file that you are going to upload<br>
`*.jpg` or `*.png` file which will be the thumbnail for your video/podcast<br>


# LBRY Desktop Application `daemon_settings.yml`
Due to the LBRY Video Platform being discontinued, the default daemon_settings that come with the LBRY Desktop application might no longer work for you due to the servers being offline.
To fix this, add the Odysee server to the top of the list of `lbryum_servers` in the following file: `C:\Users\YOURUSERNAMEHERE\AppData\Local\lbry\lbrynet\daemon_settings.yml` [Source](https://www.reddit.com/r/lbry/comments/11zwtmj/is_lbry_down/)
```
lbryum_servers:
- a-hub1.odysee.com:50001
- spv11.lbry.com:50001
- spv19.lbry.com:50001
```


# Uncaught Errors 
I have done my best to catch any possible errors that might pop up and write functionality to handle them. But If an error happens that i haven't written resolves for, it will pop up a message box that looks like this. Please send me a screenshot so I can write a patch for the bug. 

![Alt text](Assets/Screenshots/Error_Message2.png "Error Message")

# Compiling to .exe from Source
1. [Install Autohotkey v1](https://www.autohotkey.com/download/)
2. `git clone` the project and then either run the `Compile Uploader to EXE.ahk` autohotkey script to automatically compile, or start up the AHK compiler that comes installed with Autohotkey and select the `Freedomain Video Uploader.ahk` and `\Assets\FreedomainVideo.ico` icon.


# Helper Tools
The following tools will be automatically downloaded from Gitea as needed in order to do the following actions.

## LBRY-Process-Killer
Program that continuously reads the lbrynet.log for when your videos are fully uploaded/seeded to lbry and then kills the LBRY process. This can be be disabled using the `Kill LBRY after Uploading` checkbox on the main screen

## Post Scheduler
Program that continually checks the `Scheduled Posts` folder and automatically starts the Uploader with the specific video/post at the specified scheduled time.

## 