Youtube-FirstCommentBot icon indicating copy to clipboard operation
Youtube-FirstCommentBot copied to clipboard

Exception: Got empty response when trying to get the self username.

Open savagex9000 opened this issue 2 years ago • 8 comments

Hi this app is really neat but I can't seem to make it work. I followed the instructions on how to set it up and managed to get to the point where I run the command on how to add channel but I am getting this error

When I issue this command

python youbot/run.py -c confs/generic.yml -l logs/generic.log -m add_channel -u <random channel id>

The error I am getting

2022-06-29 17:43:42 FancyLogger  INFO     Logger is set. Log file path: /home/user/Youtube-FirstCommentBot/logs/generic.log
Configuration file loaded successfully from path: /home/user/Youtube-FirstCommentBot/confs/generic.yml
Configuration Tag: generic
2022-06-29 17:43:44 [generic] YoutubeApi ERROR    Got empty response when trying to get the self username.
2022-06-29 17:43:44 [generic] Main ERROR    Got empty response when trying to get the self username.
Traceback (most recent call last):
  File "youbot/run.py", line 173, in <module>
    main()
  File "youbot/run.py", line 160, in main
    youtube = YoutubeManager(config=you_conf['config'],
  File "/home/user/anaconda3/envs/youbot/lib/python3.8/site-packages/youbot-2.0-py3.8.egg/youbot/youtube_utils/youtube_manager.py", line 72, in __init__
    super().__init__(config, tag)
  File "/home/user/anaconda3/envs/youbot/lib/python3.8/site-packages/youbot-2.0-py3.8.egg/youbot/youtube_utils/youtube_api.py", line 62, in __init__
    super().__init__(config, tag)
  File "/home/user/anaconda3/envs/youbot/lib/python3.8/site-packages/youbot-2.0-py3.8.egg/youbot/youtube_utils/youtube_api.py", line 44, in __init__
    self.channel_name, self.channel_id = self._get_my_username_and_id()
  File "/home/user/anaconda3/envs/youbot/lib/python3.8/site-packages/youbot-2.0-py3.8.egg/youbot/youtube_utils/youtube_api.py", line 107, in _get_my_username_and_id
    raise Exception(error_msg)
Exception: Got empty response when trying to get the self username.

Traceback (most recent call last):
  File "youbot/run.py", line 176, in <module>
    raise e
  File "youbot/run.py", line 173, in <module>
    main()
  File "youbot/run.py", line 160, in main
    youtube = YoutubeManager(config=you_conf['config'],
  File "/home/user/anaconda3/envs/youbot/lib/python3.8/site-packages/youbot-2.0-py3.8.egg/youbot/youtube_utils/youtube_manager.py", line 72, in __init__
    super().__init__(config, tag)
  File "/home/user/anaconda3/envs/youbot/lib/python3.8/site-packages/youbot-2.0-py3.8.egg/youbot/youtube_utils/youtube_api.py", line 62, in __init__
    super().__init__(config, tag)
  File "/home/user/anaconda3/envs/youbot/lib/python3.8/site-packages/youbot-2.0-py3.8.egg/youbot/youtube_utils/youtube_api.py", line 44, in __init__
    self.channel_name, self.channel_id = self._get_my_username_and_id()
  File "/home/user/anaconda3/envs/youbot/lib/python3.8/site-packages/youbot-2.0-py3.8.egg/youbot/youtube_utils/youtube_api.py", line 107, in _get_my_username_and_id
    raise Exception(error_msg)
Exception: Got empty response when trying to get the self username.

savagex9000 avatar Jun 29 '22 17:06 savagex9000

Hello, @savagex9000 . The Youtube API is unreliable when using channel usernames. Try replacing the -u option with the -i option and use the channel id instead. If you don't know the channel id, you can use this website to do so.

drkostas avatar Jun 29 '22 18:06 drkostas

Hi @drkostas, Thanks for the quick response. I am still getting the same error. I might be doing something wrong.

(youbot) user@dracov:~/Youtube-FirstCommentBot$ python youbot/run.py -c confs/generic.yml -l logs/generic.log -m add_channel -i <any channel id I used always same error>
2022-06-29 23:47:03 FancyLogger  INFO     Logger is set. Log file path: /home/user/Youtube-FirstCommentBot/logs/generic.log
Configuration file loaded successfully from path: /home/user/Youtube-FirstCommentBot/confs/generic.yml
Configuration Tag: generic

Your browser has been opened to visit:

  <removed this part>

If your browser is on a different machine then exit and re-run this
application with the command-line parameter

  --noauth_local_webserver

Authentication successful.
2022-06-29 23:48:37 [generic] YoutubeApi ERROR    Got empty response when trying to get the self username.
2022-06-29 23:48:38 [generic] Main ERROR    Got empty response when trying to get the self username.
Traceback (most recent call last):
  File "youbot/run.py", line 173, in <module>
    main()
  File "youbot/run.py", line 160, in main
    youtube = YoutubeManager(config=you_conf['config'],
  File "/home/user/anaconda3/envs/youbot/lib/python3.8/site-packages/youbot-2.0-py3.8.egg/youbot/youtube_utils/youtube_manager.py", line 72, in __init__
    super().__init__(config, tag)
  File "/home/user/anaconda3/envs/youbot/lib/python3.8/site-packages/youbot-2.0-py3.8.egg/youbot/youtube_utils/youtube_api.py", line 62, in __init__
    super().__init__(config, tag)
  File "/home/user/anaconda3/envs/youbot/lib/python3.8/site-packages/youbot-2.0-py3.8.egg/youbot/youtube_utils/youtube_api.py", line 44, in __init__
    self.channel_name, self.channel_id = self._get_my_username_and_id()
  File "/home/user/anaconda3/envs/youbot/lib/python3.8/site-packages/youbot-2.0-py3.8.egg/youbot/youtube_utils/youtube_api.py", line 107, in _get_my_username_and_id
    raise Exception(error_msg)
Exception: Got empty response when trying to get the self username.

Traceback (most recent call last):
  File "youbot/run.py", line 176, in <module>
    raise e
  File "youbot/run.py", line 173, in <module>
    main()
  File "youbot/run.py", line 160, in main
    youtube = YoutubeManager(config=you_conf['config'],
  File "/home/user/anaconda3/envs/youbot/lib/python3.8/site-packages/youbot-2.0-py3.8.egg/youbot/youtube_utils/youtube_manager.py", line 72, in __init__
    super().__init__(config, tag)
  File "/home/user/anaconda3/envs/youbot/lib/python3.8/site-packages/youbot-2.0-py3.8.egg/youbot/youtube_utils/youtube_api.py", line 62, in __init__
    super().__init__(config, tag)
  File "/home/user/anaconda3/envs/youbot/lib/python3.8/site-packages/youbot-2.0-py3.8.egg/youbot/youtube_utils/youtube_api.py", line 44, in __init__
    self.channel_name, self.channel_id = self._get_my_username_and_id()
  File "/home/user/anaconda3/envs/youbot/lib/python3.8/site-packages/youbot-2.0-py3.8.egg/youbot/youtube_utils/youtube_api.py", line 107, in _get_my_username_and_id
    raise Exception(error_msg)
Exception: Got empty response when trying to get the self username.

savagex9000 avatar Jun 30 '22 00:06 savagex9000

Can you make sure that the Google account you are using for the YT API has a corresponding Youtube channel? If it has, can you go to this page, at the "Try this method section" and execute it for the following selection?

 part: snippet
 mine: true

Use the same Google account for authentication. The json response should have your YT channel name at the "items": [ {"snippet": {"title": ... section.

drkostas avatar Jul 02 '22 03:07 drkostas

Hmmm. Ok, so if I use the google account where the YT API is and went to page you suggested the output I get is the YT channel for that google account. But If I use the other google account that is trying to use the YT API I get a short output that account does not have a YT Channel. That other google account is the same account that I allowed as test user to use YTBOT.

savagex9000 avatar Jul 16 '22 15:07 savagex9000

@savagex9000 Can you show me the configuration file you are using?

drkostas avatar Jul 25 '22 13:07 drkostas

@drkostas this is saved on a file called .env

export DROPBOX_API_KEY=<removed>
export MYSQL_HOST=localhost
export MYSQL_USERNAME=root
export MYSQL_PASSWORD=<removed>
export MYSQL_DB_NAME=ytbot
export EMAIL_ADDRESS=<removed, used a gmail allowed to use the ytbot api>
export GMAIL_API_KEY=123 (I dont remember what this is I just leave it there)
export CLIENT_ID_GEN=<removed>
export CLIENT_SECRET_GEN=<removed>
export USERNAME_GEN=<removed>
user1@dracov:~/Youtube-FirstCommentBot$ pwd
/home/user1/Youtube-FirstCommentBot

savagex9000 avatar Jul 29 '22 06:07 savagex9000

Sorry, I meant the yml configuration file. Can you send me that? Also, you don't need the EMAIL_ADDRESS and GMAIL_API_KEY lines here.

drkostas avatar Jul 29 '22 15:07 drkostas

No worries here are the yml confs files.

user1@dracov:~/Youtube-FirstCommentBot/confs$ cat accumulator.yml
tag: accumulator
datastore:
  - config:
      hostname: !ENV ${MYSQL_HOST}  # localhost or the IP of your DB
      username: !ENV ${MYSQL_USERNAME}  # DB username
      password: !ENV ${MYSQL_PASSWORD}  # DB password
      db_name: !ENV ${MYSQL_DB_NAME}  # The name of your DB/schema
      port: 3306
    type: mysql
youtube:
  - config:
      credentials:
        - client_id: !ENV ${CLIENT_ID_ACC}  # YouTube client ID (see Readme)
          client_secret: !ENV ${CLIENT_SECRET_ACC}  # YouTube client secret (see Readme)
      api_version: v3
      read_only_scope: https://www.googleapis.com/auth/youtube.force-ssl
      username: !ENV ${USERNAME_ACC}  # Can be omitted (automatically derived). Useful when you are using a different api key for the accumulator
      comment_search_term: !ENV ${SEARCH_TERM_ACC}  # Can be omitted (username will be used instead which sometimes doesn't work). It is used to search for your comment data under a video
      sleep_time: !ENV ${SLEEP_TIME_ACC}  # Number of seconds to wait until checking for new videos again. Increase this if you are getting api limit errors
      num_comments_to_check: !ENV ${NUM_COMMENTS_ACC}  # Latest N number of comments to check and update their metadata
      load_keys_from_cloud: true  # cloudstore config is required
      keys_path: keys  # if true, cloudstore config is required. Loads the YT keys from the specified dropbox folder
    type: normal  # normal, simulated
cloudstore:  # Optional
  - config:
      api_key: !ENV ${DROPBOX_API_KEY}  # Dropbox api key, see Readme
      logs_folder_path: /yt-commenter/logs  # The Dropbox path where the log files are going to be being backed up
      keys_folder_path: /yt-commenter/keys  # The Dropbox path where the keys are going to be copied locally from
    type: dropbox
```	
	

user1@dracov:~/Youtube-FirstCommentBot/confs$ cat commenter.yml tag: commenter datastore:

  • config: hostname: !ENV ${MYSQL_HOST} # localhost or the IP of your DB username: !ENV ${MYSQL_USERNAME} # DB username password: !ENV ${MYSQL_PASSWORD} # DB password db_name: !ENV ${MYSQL_DB_NAME} # The name of your DB/schema port: 3306 type: mysql youtube:
  • config: credentials: - client_id: !ENV ${CLIENT_ID_COMM} # YouTube client ID (see Readme) client_secret: !ENV ${CLIENT_SECRET_COMM} # YouTube client secret (see Readme) - client_id: !ENV ${CLIENT_ID_COMM} # YouTube client ID (see Readme) client_secret: !ENV ${CLIENT_SECRET_COMM} # YouTube client secret (see Readme) api_version: v3 read_only_scope: https://www.googleapis.com/auth/youtube.force-ssl username: !ENV ${USERNAME_COMM} # Can be omitted (automatically derived). Useful when you are using a different api key for the accumulator load_keys_from_cloud: true # cloudstore config is required keys_path: keys # if true, cloudstore config is required. Loads the YT keys from the specified dropbox folder sleep_time: !ENV ${SLEEP_TIME_COMM} # Number of seconds to wait until checking for new videos again. Increase this if you are getting api limit errors fast_sleep_time: !ENV ${FAST_SLEEP_TIME_COMM} # Number of seconds to wait when on fast mode slow_sleep_time: !ENV ${SLOW_SLEEP_TIME_COMM} # Number of seconds to wait when on slow mode max_posted_hours: !ENV ${MAX_POSTED_HOURS_COMM} # max num. of hours to check back for posted videos. Set it to 1 the first time your run the commenter type: !ENV ${YT_API_TYPE_COMM} # normal, simulated, parallel comments: # options: normal, simulated (simulated is just for testing)
  • config: local_folder_name: comments dropbox_folder_name: /yt-commenter/comments type: !ENV ${COMMENTS_TYPE} # local, dropbox (should set cloudstore config), or mysql (not implemented) cloudstore: # Optional
  • config: api_key: !ENV ${DROPBOX_API_KEY} # Dropbox api key, see Readme logs_folder_path: /yt-commenter/logs # The Dropbox path where the log files are going to be being backed up keys_folder_path: /yt-commenter/keys # The Dropbox path where the keys are going to be copied locally from reload_data_every: !ENV ${RELOAD_DATA_EVERY} # Every how many # of loops in the commenter() to reload data and backup logs type: dropbox #emailer: # Not implemented yet

- config:

email_address: !ENV ${EMAIL_ADDRESS}

api_key: !ENV ${GMAIL_API_KEY}

type: gmail


user1@dracov:~/Youtube-FirstCommentBot/confs$ cat generic.yml tag: generic datastore:

  • config: hostname: !ENV ${MYSQL_HOST} # localhost or the IP of your DB username: !ENV ${MYSQL_USERNAME} # DB username password: !ENV ${MYSQL_PASSWORD} # DB password db_name: !ENV ${MYSQL_DB_NAME} # The name of your DB/schema port: 3306 type: mysql youtube:
  • config: credentials: - client_id: !ENV ${CLIENT_ID_GEN} # YouTube client ID (see Readme) client_secret: !ENV ${CLIENT_SECRET_GEN} # YouTube client secret (see Readme) api_version: v3 read_only_scope: https://www.googleapis.com/auth/youtube.force-ssl username: !ENV ${USERNAME_GEN} # Can be omitted (automatically derived). Useful when you are using a different api key for the accumulator load_keys_from_cloud: true # if true, cloudstore config is required. Loads the YT keys from the specified dropbox folder keys_path: keys # The local path of the YT keys type: normal # options: normal, simulated (simulated is just for testing) cloudstore: # Optional
  • config: api_key: !ENV ${DROPBOX_API_KEY} # Dropbox api key, see Readme logs_folder_path: /yt-commenter/logs # The Dropbox path where the log files are going to be being backed up keys_folder_path: /yt-commenter/keys # The Dropbox path where the keys are going to be copied locally from type: dropbox

savagex9000 avatar Jul 30 '22 02:07 savagex9000