PA2000 / YouTubeViewUpdater

This application changes the title of my video to reflect the current number of views
1 stars 1 forks source link

Multiple Client files? #1

Open ItzTej8 opened 3 years ago

ItzTej8 commented 3 years ago

Hello bro,

Can we use multiple client files? In node To set interval 1 second? Can you update this repo with multiple api keys support

PA2000 commented 3 years ago

Yes that is actually something I'm looking into. It turns out I actually hit the quota limit running this on 10 second intervals. That's because I misread the quota of 10,000 units as 10,000 requests. So presently, it turns out I can only have this code run every 7.5 -8 minutes. I'm considering support for multiple client files but upon doing some research, it turns out Google has ways to detect when someone is doing that. I don't want to have my project suspended so I may not update this repo, but I'll have to see.

ItzTej8 commented 3 years ago

Yup bro. I can use multiple keys, but I want to know how to save it using pickle. I am running my task just fo a hour in a day.

Kindly help me

This is my code :

Import pickle

api_list = create_api_list("api_files.txt");
print(api_list);
youtube = [];    
#creds = None

empty_list = []
openfile = open('token.pickle', 'wb')
pickle.dump(empty_list, openfile)
openfile.close()

for client_secrets_file in api_list:
    if os.path.exists('token.pickle'):
        with open('token.pickle', 'rb') as token:
            creds = pickle.load(token)
if not creds or not creds.valid:
    if creds and creds.expired and creds.refresh_token:
        creds.refresh(Request())
    else:
            flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file(
            client_secrets_file, SCOPES)
            creds = flow.run_local_server(port=0)
    with open('token.pickle', 'wb') as token:
        pickle.dump(creds, token)

youtube.append(googleapiclient.discovery.build(api_service_name, api_version, credentials=creds))

Where api_files.txt contains name of client files Example :

Client_file1.json
Client_file2.json
Client_file3.json

All client files present in project's root folder.

Problem is I'm not able to save login credentials in token.pickle ( just cuz multiple api keys )