linouk23 / youtube_uploader_selenium

Python script to upload videos on YouTube using Selenium
MIT License
612 stars 211 forks source link

Is it works? #67

Open shashi1iitk opened 2 years ago

shashi1iitk commented 2 years ago

As youtube is putting a lot of restrictions on automation, so just wanted to know if it still works or not.

PPBWoodBoy commented 2 years ago

no

DeveloperAidan commented 2 years ago

it does if you use it right. I've gotten it to work on a channel i made that automatically uploads rng videos and it works fine!

shashi1iitk commented 2 years ago

Thank you DeveloperAidan https://github.com/DeveloperAidan

Let me try it.

On Sat, 9 Jul 2022 at 01:03, DeveloperAidan @.***> wrote:

it does if you use it right. I've gotten it to work on a channel i made that automatically uploads rng videos and it works fine!

— Reply to this email directly, view it on GitHub https://github.com/linouk23/youtube_uploader_selenium/issues/67#issuecomment-1179303145, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGHWTL2AFHMYOGSKGPNRU3DVTB67XANCNFSM5ZK5G2YA . You are receiving this because you authored the thread.Message ID: @.***>

gartha1 commented 2 years ago

this might help

it's a text file that shows me installing it from scratch

https://web.archive.org/web/20220805133539/https://pastebin.com/raw/hY5nsZHC

https://pastebin.com/raw/hY5nsZHC

It shows different errors I ran into and that one can run into, their causes and their resolutions.

P:\abcstuff\linoukprogram\g>dir
 Volume in drive P is Charlie
 Volume Serial Number is AAEE-1F7E

 Directory of P:\abcstuff\linoukprogram\g

05/08/2022  12:46    <DIR>          .
05/08/2022  12:46    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  1,134,439,665,664 bytes free

P:\abcstuff\linoukprogram\g>

---
P:\abcstuff\linoukprogram\g>where git
C:\Program Files\Git\cmd\git.exe

P:\abcstuff\linoukprogram\g>

--

P:\abcstuff\linoukprogram\g>git clone https://github.com/linouk23/youtube_uploader_selenium
Cloning into 'youtube_uploader_selenium'...
remote: Enumerating objects: 87, done.
remote: Counting objects: 100% (54/54), done.
remote: Compressing objects: 100% (26/26), done.
Receiving objects:  75% (66/87)
Receiving objects: 100% (87/87), 16.23 KiB | 3.25 MiB/s, done.
Resolving deltas: 100% (41/41), done.

---

P:\abcstuff\linoukprogram\g>dir
 Volume in drive P is Charlie
 Volume Serial Number is AAEE-1F7E

 Directory of P:\abcstuff\linoukprogram\g

05/08/2022  12:51    <DIR>          .
05/08/2022  12:51    <DIR>          ..
05/08/2022  12:51    <DIR>          youtube_uploader_selenium
               0 File(s)              0 bytes
               3 Dir(s)  1,134,439,030,784 bytes free

P:\abcstuff\linoukprogram\g>
--

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>dir
 Volume in drive P is Charlie
 Volume Serial Number is AAEE-1F7E

 Directory of P:\abcstuff\linoukprogram\g\youtube_uploader_selenium

05/08/2022  12:51    <DIR>          .
05/08/2022  12:51    <DIR>          ..
05/08/2022  12:51             1,517 .gitignore
05/08/2022  12:51             1,074 LICENSE
05/08/2022  12:51             3,171 README.md
05/08/2022  12:51                24 requirements.txt
05/08/2022  12:51               843 upload.py
05/08/2022  12:51    <DIR>          youtube_uploader_selenium
               5 File(s)          6,629 bytes
               3 Dir(s)  1,134,439,030,784 bytes free

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>

--

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>copy .c:\carp\blah.mp4 .
        1 file(s) copied.

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>dir
 Volume in drive P is Charlie
 Volume Serial Number is AAEE-1F7E

 Directory of P:\abcstuff\linoukprogram\g\youtube_uploader_selenium

05/08/2022  12:57    <DIR>          .
05/08/2022  12:57    <DIR>          ..
05/08/2022  12:51             1,517 .gitignore
05/08/2022  11:07           125,179 blah.mp4
05/08/2022  12:51             1,074 LICENSE
05/08/2022  12:51             3,171 README.md
05/08/2022  12:51                24 requirements.txt
05/08/2022  12:51               843 upload.py
05/08/2022  12:51    <DIR>          youtube_uploader_selenium
               6 File(s)        131,808 bytes
               3 Dir(s)  1,134,438,899,712 bytes free

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>
--

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>where python
C:\Users\User\AppData\Local\Programs\Python\Python38\python.exe

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>where pip
C:\Users\User\AppData\Local\Programs\Python\Python38\Scripts\pip.exe

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>

--

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>where python
C:\Users\User\AppData\Local\Programs\Python\Python38\python.exe

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>where pip
C:\Users\User\AppData\Local\Programs\Python\Python38\Scripts\pip.exe

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>type requirements.txt
selenium_firefox==0.2.7

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>

--
P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>echo it needs selenium_firefox  

--

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>python upload.py --video blah.mp4
Traceback (most recent call last):
  File "upload.py", line 2, in <module>
    from youtube_uploader_selenium import YouTubeUploader
  File "P:\abcstuff\linoukprogram\g\youtube_uploader_selenium\youtube_uploader_selenium\__init__.py", line 5, in <module>
    from selenium_firefox.firefox import Firefox, By, Keys
ModuleNotFoundError: No module named 'selenium_firefox'

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>

---

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>pip install selenium_firefox==0.2.7
WARNING: Ignoring invalid distribution -elenium-firefox (c:\users\user\appdata\local\programs\python\python38\lib\site-packages)
WARNING: Ignoring invalid distribution -elenium-firefox (c:\users\user\appdata\local\programs\python\python38\lib\site-packages)
Collecting selenium_firefox==0.2.7
  Using cached selenium_firefox-0.2.7-py3-none-any.whl (4.7 kB)
..............
Successfully installed selenium-firefox-0.2.7
WARNING: Ignoring invalid distribution -elenium-firefox (c:\users\user\appdata\local\programs\python\python38\lib\site-packages)
WARNING: Ignoring invalid distribution -elenium-firefox (c:\users\user\appdata\local\programs\python\python38\lib\site-packages)
WARNING: Ignoring invalid distribution -elenium-firefox (c:\users\user\appdata\local\programs\python\python38\lib\site-packages)
WARNING: You are using pip version 21.1.1; however, version 22.2.2 is available.
You should consider upgrading via the 'c:\users\user\appdata\local\programs\python\python38\python.exe -m pip install --upgrade pip' command

----

^^ Successfully installed selenium-firefox-0.2.7 <-- note that above

---

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>pip show selenium-firefox
Name: selenium-firefox
Version: 0.2.7
Summary: selenium_firefox
Home-page: https://github.com/kkristof200/selenium_firefox
Author: Kovács Kristóf-Attila
Author-email: None
License: UNKNOWN
Location: c:\users\user\appdata\local\programs\python\python38\lib\site-packages
Requires: tldextract, fake-useragent, selenium
Required-by:

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>

--
^^ good hasn't done the latest version, has the version in requirements.txt
--

it needs a version of the selenium package installed that isn't the latest.

selenium 3.141.0 works.

it's one of the latest in the version 3 selenium https://github.com/SeleniumHQ/selenium/releases?page=3
and it can be installed with pip install

Now two possible errors you might get running python upload.py --video blah.mp4

one if you haven't installed the selenium package, and one if it's a later version of it that you installed

if haven't installed selenium

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>pip uninstall selenium
WARNING: Ignoring invalid distribution -elenium-firefox (c:\users\user\appdata\local\programs\python\python38\lib\site-packages)
WARNING: Ignoring invalid distribution -elenium-firefox (c:\users\user\appdata\local\programs\python\python38\lib\site-packages)
WARNING: Skipping selenium as it is not installed.

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>pip show selenium
WARNING: Package(s) not found: selenium

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>python upload.py --video blah.mp4
Traceback (most recent call last):
  File "upload.py", line 2, in <module>
    from youtube_uploader_selenium import YouTubeUploader
  File "P:\abcstuff\linoukprogram\g\youtube_uploader_selenium\youtube_uploader_selenium\__init__.py", line 5, in <module>
    from selenium_firefox.firefox import Firefox, By, Keys
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium_firefox\firefox.py", line 4, in <module>
    from selenium.webdriver.support.ui import WebDriverWait
ModuleNotFoundError: No module named 'selenium.webdriver.support'

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>

--

supposing selenium is installed but the version is too late

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>pip install selenium
WARNING: Ignoring invalid distribution -elenium-firefox (c:\users\user\appdata\local\pro
WARNING: Ignoring invalid distribution -elenium-firefox (c:\users\user\appdata\local\pro
Collecting selenium
  Using cached selenium-4.3.0-py3-none-any.whl (981 kB)
Requirement already satisfied: urllib3[secure,socks]~=1.26 in c:\users\user\appdata\loca
elenium) (1.26.11)

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>pip show selenium
Name: selenium
Version: 4.3.0
Summary: None
Home-page: https://www.selenium.dev
Author: None
Author-email: None
License: Apache 2.0
Location: c:\users\user\appdata\local\programs\python\python38\lib\site-packages
Requires: trio, urllib3, trio-websocket
Required-by: -elenium-firefox, selenium-firefox, selenium-browser

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>python upload.py --video blah.mp4
Traceback (most recent call last):
  File "upload.py", line 22, in <module>
    main(args.video, args.meta, args.thumbnail)
  File "upload.py", line 7, in main
    uploader = YouTubeUploader(video_path, metadata_path, thumbnail_path)
  File "P:\abcstuff\linoukprogram\g\youtube_uploader_selenium\youtube_uploader_selenium\__init__.py", line 33, in __init__
    self.browser = Firefox(current_working_dir, current_working_dir)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\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'

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>python upload.py --video blah.mp4
Traceback (most recent call last):
  File "upload.py", line 22, in <module>
    main(args.video, args.meta, args.thumbnail)
  File "upload.py", line 7, in main
    uploader = YouTubeUploader(video_path, metadata_path, thumbnail_path)
  File "P:\abcstuff\linoukprogram\g\youtube_uploader_selenium\youtube_uploader_selenium\__init__.py", line 33, in __init__
    self.browser = Firefox(current_working_dir, current_working_dir)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\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'

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>

--

if you have selenium version correct then that's good, you just get a message about geckodriver

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>pip install selenium==3.141.0
...
Successfully installed selenium-3.141.0
WARNING: Ignoring invalid distribution -elenium-firefox (c:\users\user\appdata\local\programs\python\python38\lib\site-packages)
WARNING: Ignoring invalid distribution -elenium-firefox (c:\users\user\appdata\local\programs\python\python38\lib\site-packages)
WARNING: Ignoring invalid distribution -elenium-firefox (c:\users\user\appdata\local\programs\python\python38\lib\site-packages)
WARNING: You are using pip version 21.1.1; however, version 22.2.2 is available.
You should consider upgrading via the 'c:\users\user\appdata\local\programs\python\python38\python.exe -m pip install --upgrade pip' command
.

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>pip show selenium
Name: selenium
Version: 3.141.0
Summary: Python bindings for Selenium
Home-page: https://github.com/SeleniumHQ/selenium/
Author: UNKNOWN
Author-email: UNKNOWN
License: Apache 2.0
Location: c:\users\user\appdata\local\programs\python\python38\lib\site-packages
Requires: urllib3
Required-by: -elenium-firefox, selenium-firefox, selenium-browser

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>python upload.py --video blah.mp4
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 1311, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "upload.py", line 22, in <module>
    main(args.video, args.meta, args.thumbnail)
  File "upload.py", line 7, in main
    uploader = YouTubeUploader(video_path, metadata_path, thumbnail_path)
  File "P:\abcstuff\linoukprogram\g\youtube_uploader_selenium\youtube_uploader_selenium\__init__.py", line 33, in __init__
    self.browser = Firefox(current_working_dir, current_working_dir)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium_firefox\firefox.py", line 86, in __init__
    self.driver = webdriver.Firefox(firefox_profile=profile, firefox_options=options)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init
__
    self.service.start()
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>

--

https://github.com/mozilla/geckodriver/releases/download/v0.31.0/geckodriver-v0.31.0-win64.zip

--

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>dir
 Volume in drive P is Charlie
 Volume Serial Number is AAEE-1F7E

 Directory of P:\abcstuff\linoukprogram\g\youtube_uploader_selenium

05/08/2022  13:35    <DIR>          .
05/08/2022  13:35    <DIR>          ..
05/08/2022  12:51             1,517 .gitignore
05/08/2022  11:07           125,179 blah.mp4
05/08/2022  12:03         3,738,640 geckodriver.exe
05/08/2022  13:22                 0 geckodriver.log
05/08/2022  12:51             1,074 LICENSE
05/08/2022  12:51             3,171 README.md
05/08/2022  12:51                24 requirements.txt
05/08/2022  12:51               843 upload.py
05/08/2022  13:00    <DIR>          youtube_uploader_selenium
               8 File(s)      3,870,448 bytes
               3 Dir(s)  1,134,435,127,296 bytes free

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>

--

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>python upload.py --video blah.mp4
WARNING:youtube_uploader_selenium:The video title was not found in a metadata file
WARNING:youtube_uploader_selenium:The video title was set to blah
WARNING:youtube_uploader_selenium:The video description was not found in a metadata file
INFO:youtube_uploader_selenium:Please sign in and then press enter

--
now firefox comes up and isn't signed in

and cmd prompt prompts you to sign in in the browser
--

but it says 

"This browser or app may not be secure."

--

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>python upload.py --video blah.mp4
WARNING:youtube_uploader_selenium:The video title was not found in a metadata file
WARNING:youtube_uploader_selenium:The video title was set to blah
WARNING:youtube_uploader_selenium:The video description was not found in a metadata file
INFO:youtube_uploader_selenium:Please sign in and then press enter
Traceback (most recent call last):
  File "upload.py", line 22, in <module>
    main(args.video, args.meta, args.thumbnail)
  File "upload.py", line 8, in main
    was_video_uploaded, video_id = uploader.upload()
  File "P:\abcstuff\linoukprogram\g\youtube_uploader_selenium\youtube_uploader_selenium\__init__.py", line 56, in upload
    self.__login()
  File "P:\abcstuff\linoukprogram\g\youtube_uploader_selenium\youtube_uploader_selenium\__init__.py", line 73, in __login
    input()
KeyboardInterrupt
^C
P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>

--

find the profile folder, which is under the three lines menu...help...more troubleshooting information

then see "profile folder", and it says  

C:\Users\User\AppData\Roaming\Mozilla\Firefox\Profiles\somerandomstuff.default

e.g.

C:\Users\User\AppData\Roaming\Mozilla\Firefox\Profiles\pdp510ax.default

--
somewhere deep within "C:\Users\USER\    is firefox.py

e.g.

"C:\Users\USER\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5fsdfs8p0\LocalCache\local-packages\Python310\site-packages\selenium_firefox\firefox.py

mine is here

C:\Users\User>dir firefox.py /s/b
C:\Users\User\AppData\Local\Programs\Python\Python38\Lib\site-packages\selenium_firefox\firefox.py

C:\Users\User>

find this line

    profile = webdriver.FirefoxProfile()

and change it to e.g.

 profile= webdriver.FirefoxProfile('/home/your_user_name/.mozilla/firefox/some_letters.default-release/')
which for me on windows is

or

    profile= webdriver.FirefoxProfile('/Users/user/AppData/Roaming/Mozilla/Firefox/Profiles/some_letters.default-release/')

whatever your profile folder is

Mine on this computer is  a Profile Folder    C:\Users\User\AppData\Roaming\Mozilla\Firefox\Profiles\pdp510jx.default

so I changed it to

profile = webdriver.FirefoxProfile("C:/Users/User/AppData/Roaming/Mozilla/Firefox/Profiles/pdp510jx.default")

--

C:\Users\User>findstr /i firefoxprofile "C:/Users/User/AppData/Local/Programs/Python/Python38/Lib/site-packages/selenium_firefox/firefox.py"

        profile = webdriver.FirefoxProfile()

C:\Users\User>

C:\Users\User>echo now I change that
now I change that

C:\Users\User>wordpad "C:/Users/User/AppData/Local/Programs/Python/Python38/Lib/site-packages/selenium_firefox/firefox.py"

C:\Users\User>findstr /i firefoxprofile "C:/Users/User/AppData/Local/Programs/Python/Python38/Lib/site-packages/selenium_firefox/firefox.py"

        profile = webdriver.FirefoxProfile("C:/Users/User/AppData/Roaming/Mozilla/Firefox/Profiles/pdp510jx.default")

C:\Users\User>

--

it asks you to sign in though you are signed in so just press enter for that.
--

P:\abcstuff\linoukprogram\g\youtube_uploader_selenium>python upload.py --video blah.mp4
WARNING:youtube_uploader_selenium:The video title was not found in a metadata file
WARNING:youtube_uploader_selenium:The video title was set to blah
WARNING:youtube_uploader_selenium:The video description was not found in a metadata file
INFO:youtube_uploader_selenium:Please sign in and then press enter

--

and you should see it go through the form to upload.
--

now open firefox and youtube.com and go to youtube studio and see if it uploaded
--
jamesjiayu commented 9 months ago

@gartha1 good job