linouk23 / youtube_uploader_selenium Goto Github PK
View Code? Open in Web Editor NEWPython script to upload videos on YouTube using Selenium
License: MIT License
Python script to upload videos on YouTube using Selenium
License: MIT License
Crash occurs on line 77, which says title_field.click()
which comes after title_field = self.browser.find(By.ID, Constant.TEXTBOX)
.
Firefox opens and logs in correctly, but crashes very shortly after. Here is the full error:
'NoneType' object has no attribute 'click'
Traceback (most recent call last):
File "/home/lostrobot/Automation Stuff/Uploader/YoutubeUploader.py", line 125, in <module>
was_video_uploaded, video_id = uploader.upload()
File "/home/lostrobot/.local/lib/python3.8/site-packages/youtube_uploader_selenium/__init__.py", line 47, in upload
return self.__upload()
File "/home/lostrobot/.local/lib/python3.8/site-packages/youtube_uploader_selenium/__init__.py", line 77, in __upload
title_field.click()
AttributeError: 'NoneType' object has no attribute 'click'
I am using Ubuntu 20.04.
Thanks for the help in advance. I only have a few days to get this working, so I would be eternally grateful for a quick reply.
I want to be able to just upload the video to youtube as a DRAFT, so that It's no longer in my local computer but is in youtube servers, and be able to edit, add, thumbnail, captions etc later. Is it possible?
insecure browser error.
Traceback (most recent call last):
File "C:\Users\felip\OneDrive\Documentos\bots\youtubebot\test.py", line 22, in
finalVideoId = youtubeUplaodVideoSelenium(videoFile, videoThumb, videoThumb)
File "C:\Users\felip\OneDrive\Documentos\bots\youtubebot\youtube.py", line 336, in youtubeUplaodVideoSelenium
uploader = YouTubeUploader(file, metadata, thumbnail)
File "C:\Users\felip\OneDrive\Documentos\bots\youtubebot\youtube_uploader_init_.py", line 31, in init
self.metadata_dict = load_metadata(metadata_json_path)
File "C:\Users\felip\OneDrive\Documentos\bots\youtubebot\youtube_uploader_init_.py", line 21, in load_metadata
return defaultdict(str, json.load(metadata_json_file))
File "C:\Users\felip\AppData\Local\Programs\Python\Python310\lib\json_init_.py", line 293, in load
return loads(fp.read(),
File "C:\Users\felip\AppData\Local\Programs\Python\Python310\lib\codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
PS C:\Users\felip\OneDrive\Documentos\bots\youtubebot>
Hello,
How to upload multiple videos?
I'd like to use this on a few raspberry pis. But I don't want to graphically launch firefox on each to generate a credentials file. Can I do it on just one and then copy this credentials to other machines?
The reason I do not want to launch firefox on each one is because I am running all these machines headless . They are on a local network and not directly accessible . I have to login to a "jump server" to get to them. It's possible , but a bit of a pain to have to tunnel VNC graphics through them and the jump server..
My problem is that after script finishes, it closes firefox and upload stops. Also Thumbnail and Tags are missing, kinda big deal with automation
can you please make a detailed guide on how to solve this issue.
as how to export cookies in firefox and import them
selenium_firefox/firefox.py", line 86, in init
self.driver = webdriver.Firefox(firefox_profile=profile, firefox_options=options)
TypeError: init() got an unexpected keyword argument 'firefox_options'
Does anyone know what the problem is here?
Gui works fine,
when I switch to headless, the video container seems to not be found.
AttributeError: 'NoneType' object has no attribute 'send_keys
Traceback (most recent call last):
File "E:/audio_book/upload.py", line 6, in
uploader = YouTubeUploader(video_path,metadata_path)
File "C:\Users\a\AppData\Local\Programs\Python\Python38\lib\site-packages\youtube_uploader_selenium_init_.py", line 29, in init
self.metadata_dict = load_metadata(metadata_json_path)
File "C:\Users\a\AppData\Local\Programs\Python\Python38\lib\site-packages\youtube_uploader_selenium_init_.py", line 20, in load_metadata
return defaultdict(str, json.load(metadata_json_file))
File "C:\Users\a\AppData\Local\Programs\Python\Python38\lib\json_init_.py", line 293, in load
return loads(fp.read(),
UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 23: illegal multibyte sequence
I'm with this error
File "C:\Users\felip\OneDrive\Documentos\bots\youtubebot\youtube_uploader_init_.py", line 33, in init
self.browser = Firefox(current_working_dir, current_working_dir)
File "C:\Users\felip\OneDrive\Documentos\bots\youtubebot\venv\lib\site-packages\selenium_firefox\firefox.py", line 86, in init
self.driver = webdriver.Firefox(firefox_profile=profile, firefox_options=options)
TypeError: WebDriver.init() got an unexpected keyword argument 'firefox_options'
The XPATH changed again, does anyone know the fix?
It should be the part that uploads thumbnails
Message: Element
how to select playlist or add playlist
It works perfectly when I'm running on Windows, but when I'm running on centos, I get this error, of course, headless browser.
I can't actually find the overwritten element on the page
Element is not clickable at point (804,207) because another element obscures it
system:
firefox v77
mac osx big sur
need to pass first step headlessly, how to do it?
xpath path update
all works fines,
login, upload, thumbnail, title,
but few time after my title are set, my description overwrite it
anyone know how to fix this ?
$ python3 upload.py --video video.mp4
Traceback (most recent call last):
File "upload.py", line 2, in <module>
from youtube_uploader_selenium import YouTubeUploader
File "/home/test/projetcs/youtube_uploader_selenium/youtube_uploader_selenium/__init__.py", line 5, in <module>
from selenium_firefox.firefox import Firefox, By, Keys
ImportError: cannot import name 'By' from 'selenium_firefox.firefox' (/home/test/.local/lib/python3.7/site-packages/selenium_firefox/firefox.py)
As I understood the script uses firefox, but firefox does not work without Linux GUI.
I get
Traceback (most recent call last):
File "upload.py", line 19, in <module>
main(args.video, args.meta)
File "upload.py", line 7, in main
uploader = YouTubeUploader(video_path, metadata_path)
File "/home/azat/youtube_uploader_selenium/youtube_uploader_selenium/__init__.py", line 31, in __init__
self.browser = Firefox(current_working_dir, current_working_dir)
File "/usr/local/lib/python3.7/dist-packages/selenium_firefox/firefox.py", line 178, in __init__
firefox_binary=ff_binary
File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
keep_alive=True)
File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 1
Error - Firefox: quit() - 'Firefox' object has no attribute 'driver'
DEBUG:youtube_uploader_selenium:Attached video test.mp4
DEBUG:youtube_uploader_selenium:The video title was set to "Best Of James Harden | 2019-20 NBA Season"
DEBUG:youtube_uploader_selenium:The video description was set to "Check out the best of James Harden's 2019-20 season so far!"
DEBUG:youtube_uploader_selenium:Selected "NOT_MADE_FOR_KIDS"
DEBUG:youtube_uploader_selenium:Clicked next-button
DEBUG:youtube_uploader_selenium:Clicked another next-button
'NoneType' object has no attribute 'click'
Traceback (most recent call last):
File "E:/dev/uploady/eradinus.py", line 11, in
was_video_uploaded, video_id = uploader.upload()
File "E:\dev\Anaconda\lib\site-packages\youtube_uploader_selenium_init_.py", line 47, in upload
return self._upload()
File "E:\dev\Anaconda\lib\site-packages\youtube_uploader_selenium_init.py", line 110, in __upload
self.browser.find(By.ID, Constant.RADIO_LABEL, public_main_button).click()
AttributeError: 'NoneType' object has no attribute 'click'
Process finished with exit code 1
The next button in the checks column is blue and can be clicked but the program waits for 10 seconds and crashes here.
firefox = 77
geckodriver = ?
selenium = ?
can you add chrome support?
use chromedriver
Tuple expression not allowed in type annotation
Use Tuple[T1, ..., Tn] to indicate a tuple type or Union[T1, T2] to indicate a union type
Second error:
ImportError: cannot import name 'By' from 'selenium_firefox.firefox' (C:\Users\d\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium_firefox\firefox.py)
Is there a way to watch a folder? so whenever a new video appears it will execute the script?
My title is set to the title in my metadata.json and the default title youtube gives, is there a way to fix that ?
Does the meta json file handle tags?
Hello,
First of all, thanks for this amazing code. I just want to mention a few issues I saw while working with this package. I am using Windows, so some of the issues might be because of it. (I believe the code is implemented for MAC)
The code is a bit old, so if you encounter the error "This browser or app may not be secure" in the first login process, just try an older version of FireFox (I made it work with version 77).
It misses a third click on the next button in the uploading process. Otherwise it will stuck at Checks dialogue and does not complete the uploading process. Just add another click on the next button in init.py file line 139:
self.browser.find(By.ID, Constant.NEXT_BUTTON).click()
self.logger.debug('Clicked another another {}'.format(Constant.NEXT_BUTTON))
(There is already a commit that fixes this issue + updates in the constant variables)
video_description = self.metadata_dict[Constant.VIDEO_DESCRIPTION]
video_description = video_description.replace("\n", Keys.ENTER);
if video_description:
description_field = self.browser.find_all(By.ID, Constant.TEXTBOX)[1]
self.__write_in_field(description_field, video_description, select_all=True)
self.logger.debug('Set the description.')
field.send_keys(Keys.CONTROL + 'a')
{
"title": "Test Title",
"description": "Test Description.",
"tags": ["test1", "test2", "test3"]
}
I believe these are the changes I made to make this work for me. Again, Thanks a lot to @linouk23 for making the code public.
Couldn’t sign you in
This browser or app may not be secure. Learn more
Try using a different browser. If you’re already using a supported browser, you can try again to sign in.
I want to use the package in AWS Lightsail, but I am using ubuntu which I believe doesn't provide RDP or something like that except for a terminal, Is there a way for me to not authenticate in a browser ( for a brand account ) ?
if have some videos and thumbnails , how to upload them at the same time?
it closes the window before uploading anything and I get this message
Message: Element is not clickable at point (1124,207) because another element obscures it
Tried to upload a video file which is of 5 GB. Before the file gets fully uploaded the browser closes after filling all the forms and hence leading to fail in uploading videos.
I think there should be a check where the browser closes once the file gets uploaded.
Hi, been getting this issue with using the master branch:
ElementClickInterceptedException: Element is not clickable at point (1124,207) because another element
any idea what it is about, and how to fix it? Using windows 10.
I had to change my pc. After setting everything up I can't log in anymore. Any solution?
Traceback (most recent call last):
File "F:\test\222\youtube_uploader_selenium-master\uup.py", line 7, in
uploader = YouTubeUploader(video_path, metadata_path, thumbnail_path)
File "F:\test\222\youtube_uploader_selenium-master\youtube_uploader_selenium_init_.py", line 33, in init
self.browser = Firefox(current_working_dir, current_working_dir)
File "F:\test\222\youtube_uploader_selenium-master\venv\lib\site-packages\selenium_firefox\firefox.py", line 86, in init
self.driver = webdriver.Firefox(firefox_profile=profile, firefox_options=options)
TypeError: init() got an unexpected keyword argument 'firefox_options'
How to solve this problem ?
With official Youtube API, we have an option to specify a custom thumbnail for the video. Such functionality can be included here as well.
Traceback (most recent call last):
File "upload.py", line 1, in
from youtube_uploader_selenium import YouTubeUploader
File "/home/ubuntu/.local/lib/python3.8/site-packages/youtube_uploader_selenium/init.py", line 5, in
from selenium_firefox.firefox import Firefox, By, Keys
ImportError: cannot import name 'By' from 'selenium_firefox.firefox' (/home/ubuntu/.local/lib/python3.8/site-packages/selenium_firefox/firefox.py)
Due to change in the xpath in youtube studio the upload fails. Will need an update on xpath variables in constant.py
.
Hi Linouk23,
I have a suggestion to add a multi accounts support for this script.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.