Coder Social home page Coder Social logo

offish / opplast Goto Github PK

View Code? Open in Web Editor NEW
34.0 3.0 18.0 61 KB

Upload videos to YouTube using geckodriver, Firefox profiles and Selenium.

License: MIT License

Python 100.00%
youtube youtube-upload youtube-uploader selenium selenium-webdriver selenium-python youtube-video youtube-channel geckodriver upload-videos youtube-uploads

opplast's Introduction

opplast

Version License Stars Issues Size Discord Code style

Donate Steam Donate PayPal

Upload videos to YouTube using geckodriver, Firefox profiles and Selenium. Easy to setup and use. Inspired by youtube_uploader_selenium.

"Opplast" is norwegian for "upload".

Installing

Install and update using pip:

pip install --upgrade opplast

geckodriver

Download geckodriver and place it inside C:\Users\USERNAME\AppData\Local\Programs\Python\Python37. If you are using another version of Python, you place it inside there. This only works if Python is added to PATH and it is the correct version.

You can check if geckodriver has been added to PATH by running geckodriver --version in the terminal. If this gives you an error or you are running into:

selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

Specify executable_path in the Configuration part.

Configuration

Open Firefox, and go to about:profiles. Click "Create a New profile" and name it "Selenium" or whatever. Copy the "Root Directory" path of the new profile. This is your root_profile_directory. Now you can "Launch profile in new browser", go to YouTube, and login to the account you want to upload with.

It's highly recommended that you clear your standard upload settings on YouTube.

Upload(root_profile_directory: str, executable_path: str = "geckodriver", timeout: int = 3, headless: bool = True, debug: bool = True, options: FirefoxOptions = webdriver.FirefoxOptions()) -> None

root_profile_directory: str - path to Firefox profile where you're logged into YouTube.

executable_path: str - full path to override which geckodriver binary to use for Firefox 47.0.1 and greater, which defaults to picking up the binary from the system path. Example: r"C:/Users/USERNAME/Desktop/geckodriver" (if geckodriver.exe is located in Desktop folder) Default: geckodriver.

timeout: int - seconds Selenium should wait, when getting pages and inserting data. Default: 3.

headless: bool - whether or not you want to see the browser GUI. Will override headless option if specified in options. Default: True (hidden).

debug: bool - whether or not you want to see the debug info. Default: True (shown).

options: FirefoxOptions - optional options for webdriver. Use headless if you want to hide browser.

Usage

from opplast import Upload


upload = Upload(
    # use r"" for paths, this will not give formatting errors e.g. "\n"
    r"C:/Users/USERNAME/AppData/Roaming/Mozilla/Firefox/Profiles/r4Nd0m.selenium",
)

was_uploaded, video_id = upload.upload(
    r"C:/path/to/video.mp4",
    title="My YouTube Title",
    description="My YouTube Description",
    thumbnail=r"C:/path/to/thumbnail.jpg",
    tags=["these", "are", "my", "tags"],
    only_upload=False # If True will not set title, description or anything else. 
    # Might be useful if you want to do it manually or by using the YouTube API.
)

if was_uploaded:
    print(f"{video_id} has been uploaded to YouTube")

upload.close()

License

MIT License

Copyright (c) 2021 offish

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

opplast's People

Contributors

breuerfelix avatar lentilstew avatar markdrrr avatar offish avatar powaful3000 avatar r-yeates avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

opplast's Issues

Hi

Im sorry i don't know what I did, i think I edited a file, I'm new to github, I wanted to add the option to put tags in videos but I think I edited for everyone, i don't know how this works

Unable to locate element

There was an error Message: Unable to locate element: /html/body/ytcp-uploads-dialog/tp-yt-paper-dialog/div/ytcp-animatable[1]/ytcp-ve/ytcp-video-metadata-editor/div/ytcp-video-metadata-editor-basics/div[2]/ytcp-social-suggestions-textbox/ytcp-form-input-container/div[1]/div[2]/div/ytcp-social-suggestion-input
when trying to upload to YouTube

entrance

How does the login process work?

Error uploading video

Hello! Thanks for creating this!

I look to be getting this error when using Upload. It does upload the video, but doesn't publish

DEBUG: Trying to set "...." as description...
Error: Message: Unable to locate element: /html/body/ytcp-uploads-dialog/tp-yt-paper-dialog/div/ytcp-animatable[1]/ytcp-video-metadata-editor/div/ytcp-video-metadata-editor-basics/div[2]/ytcp-mention-textbox/ytcp-form-input-container/div[1]/div[2]/ytcp-mention-input

Unable to locate element

Hello, seems like it cannot find an element?

error: There was an error Message: Unable to locate element: /html/body/ytcp-uploads-dialog/tp-yt-paper-dialog/div/ytcp-animatable[1]/ytcp-video-metadata-editor/div/ytcp-video-metadata-editor-basics/div[2]/ytcp-social-suggestions-textbox/ytcp-form-input-container/div[1]/div[2]/ytcp-mention-input when trying to upload to YouTube

Thanks

Add Customize executable_path

self.driver = webdriver.Firefox(firefox_profile=profile, options=options)

add more param executable_path

self.driver = webdriver.Firefox(firefox_profile=profile, options=options, executable_path='./geckodriver')

or use **kwargs to pass param when init webdrive.Firefox() ?

unable to locate element

It cant upload and states the following
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //input[@type='file']

Error: any ideas?

Hey Thanks for doing this. Very cool and easy.

it was working fine until today. i did pull your latest release. getting this error today using your sample code with a valid file location. on Windows 10 and FF 86.0 (64-bit)

PS C:\Users\johnj> & python c:/Users/johnj/Desktop/auto-downloader/TestUpload03152021.py
DEBUG: Firefox is now running
DEBUG: Trying to upload "D:/ToYouTube/upload/365tour.mp4" to YouTube...
DEBUG: Trying to set "My YouTube Title" as title...
DEBUG: Trying to set "My YouTube Description" as description...
Traceback (most recent call last):
File "c:/Users/johnj/Desktop/auto-downloader/TestUpload03152021.py", line 8, in
was_uploaded, video_id = upload.upload(
File "C:\Users\johnj\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\opplast\upload.py", line 78, in upload
container = self.driver.find_element_by_xpath(DESCRIPTION_CONTAINER)
File "C:\Users\johnj\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webdriver\remote\webdriver.py", line
394, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\Users\johnj\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webdriver\remote\webdriver.py", line
976, in find_element
return self.execute(Command.FIND_ELEMENT, {
File "C:\Users\johnj\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webdriver\remote\webdriver.py", line
321, in execute
self.error_handler.check_response(response)
File "C:\Users\johnj\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: /html/body/ytcp-uploads-dialog/tp-yt-paper-dialog/div/ytcp-animatable[1]/ytcp-uploads-details/div/ytcp-uploads-basics/ytcp-mention-textbox[2]

show upload progress

status_container.text.find(UPLOADED)

With this we can get the progress text and output it on the command line。

Unable to find clips for specific streamers

The script cannot find clips from a certain streamer despite other streamers working fine

image
image

the config file is completely stock except for length which is 10 minutes and timeframe which is set to 0 (all time)

selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //input[@type='file']

I'm experiencing this error. That's my script

from opplast import Upload

if __name__ == "__main__":
    upload = Upload(
        # use r"" for paths, this will not give formatting errors e.g. "/n"
        r"C:/Users/SpookyToad/AppData/Roaming/Mozilla/Firefox/Profiles/oysfbms4.selenium",
    )

    video_id = upload.upload(
        r"E:\mc_video\video.mp4",
        title="My YouTube Title",
        description="My YouTube Description",
        thumbnail=r"E:\mc_video\thumbnail.jpg",
        tags=["these", "are", "my", "tags"],
    )

    #if was_uploaded:
    #    print(f"{video_id} has been uploaded to YouTube")

    upload.close()

It says that error happens in script Upload at 80th line

    self.driver.find_element_by_xpath(INPUT_FILE_VIDEO).send_keys(get_path(file))
    sleep(self.timeout)

How i'm able to fix that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.