linouk23 / youtube_uploader_selenium

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

This browser or app may not be secure. #39

Open NoString opened 3 years ago

NoString commented 3 years ago

hi, developer. I try to use this python code, but when I login youtube, it notice me that "browser is not secure", how can I do? my firefox version is 89.0 and had installed and configure the geckodriver image

terahlunah commented 3 years ago

I have the same issue

rzfzr commented 3 years ago

You don't log in, just load the cookies, get them with a extension like editThisCookie

async function setCookies(channelName) { let p = require("electron").remote.app.getAppPath(); p = p.substring(0, p.lastIndexOf("\\")); let cookieJar = JSON.parse( fs.readFileSync( p + "/cookieJar/" + (channelName || "Só idéias legais!") + ".json", "utf8" ) ); cookieJar.forEach(async (cookie) => { cookie.sameSite = "None"; cookie.storeId = "None"; cookie.secure = true; await driver.manage().addCookie(cookie); }); }

pokima commented 3 years ago

You don't log in, just load the cookies, get them with a extension like editThisCookie

async function setCookies(channelName) { let p = require("electron").remote.app.getAppPath(); p = p.substring(0, p.lastIndexOf("\\")); let cookieJar = JSON.parse( fs.readFileSync( p + "/cookieJar/" + (channelName || "Só idéias legais!") + ".json", "utf8" ) ); cookieJar.forEach(async (cookie) => { cookie.sameSite = "None"; cookie.storeId = "None"; cookie.secure = true; await driver.manage().addCookie(cookie); }); }

I use editthiscookie to get the same cookies for different channels

rzfzr commented 3 years ago

@pokima yes, even the same account as manager for multiple channels/brand accounts, you can get different cookies and use them

NoNoNe96 commented 3 years ago

You don't log in, just load the cookies, get them with a extension like editThisCookie

async function setCookies(channelName) { let p = require("electron").remote.app.getAppPath(); p = p.substring(0, p.lastIndexOf("\\")); let cookieJar = JSON.parse( fs.readFileSync( p + "/cookieJar/" + (channelName || "Só idéias legais!") + ".json", "utf8" ) ); cookieJar.forEach(async (cookie) => { cookie.sameSite = "None"; cookie.storeId = "None"; cookie.secure = true; await driver.manage().addCookie(cookie); }); }

How do I get Login Cookies?

rzfzr commented 3 years ago

How do I get Login Cookies? Did you try the extension? just click the icon > export > paste them

gartha1 commented 2 years ago

I don't quite understand.. So I run firefox I use that cookie editor extension, go to youtube while logged in, and click the export button in cookie editor, to copy the cookies.

So now I have cookie data in my clipboard.

I could put that in a file c:\thispythonproject\cookie.json

But how do I get this program to load the cookies from that file?

A comment mentions "async function setCookies(channelName) {.........}"

Well, having done a bit of javascript before, I suppose that's javascript rather than python.

Where am I meant to put that javascript line?

And I suppose straight after that line there should be a line that calls it?

I guess Selenium will run a browser or headless browser, and it's doing that so that's fine, but I suppose there must be a way to inject javascript into a page, and if injecting it into the right page then hey presto it could work.

But could anybody please explain how to do that?

(So I can go from having that cookie data, in a json file, to getting the cookies auto loaded into the browser that the program starts?)

Thanks

UPDATE-

I see a solution here that works https://github.com/linouk23/youtube_uploader_selenium/issues/39

You find firefox.py which for me is

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

And you find this line

    profile = webdriver.FirefoxProfile()

and you want to comment that / change that to something like he said

    #  profile= webdriver.FirefoxProfile('/home/your_user_name/.mozilla/firefox/some_letters.default-release/')

which for me on windows is

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

To get the exact path of the profile that has you logged into your youtube profile , you can open firefox go to help.. troubleshooting.. and it says "profile folder" and tells you the path to that folder.

Now even if I comment out that line to load my default profile, and it just uses profile = webdriver.FirefoxProfile() it seems to be loading my default profile. So all fine.

At one point when trying something I noticed that at the cmd prompt it asked me to log in and then push ENTER. So, even if it wasn't logged in, maybe there's that method too. So worth checking to see what it says at the cmd prompt.