Skip to content

Commit

Permalink
Add Channel ID retrieval tool
Browse files Browse the repository at this point in the history
Create new user_tools.py script and "helpful tools" main menu option. Allows one to look up the Channel ID of a channel based on a video URL.
  • Loading branch information
ThioJoe committed Dec 11, 2022
1 parent 91276e6 commit 968e0cb
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 5 deletions.
71 changes: 71 additions & 0 deletions Scripts/user_tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
from Scripts.shared_imports import *
import Scripts.auth as auth
import Scripts.validation as validation
import Scripts.utils as utils

################################ USER TOOLS MENU ###########################################
def user_tools_menu(config):
print(f"\n\n-------------------- {F.LIGHTGREEN_EX}Helpful Tools{S.R} --------------------")
print(f" 1. Get Channel ID from Video URL")
print("")

validMode:bool = False
while not validMode:
toolChoice = input("Choice: ")

# Check if user wants to go back
if toolChoice == "x":
return "MainMenu"

# Check if valid choice
validChoices = ['1']
if toolChoice in validChoices:
validMode = True

# Call the appropriate function
if toolChoice == "1":
result = video_to_channel_id()

#--------------------------------------------
# Check if user wants to go back
if str(result) == "MainMenu":
return "MainMenu"

else:
print(f"{F.LIGHTRED_EX}Invalid Choice!\n{S.R}")


################################ VIDEO URL TO CHANNEL ID ###########################################
def video_to_channel_id():
print(f"\n\n-------------------- Video URL to Channel ID --------------------")
print(f"{F.YELLOW}How To Use:{S.R} Enter a video URL and this tool will return the channel ID of the uploader.")
print("")

validChoice = False
while not validChoice:
urlInput = input("Video URL: ")

# Check if user wants to go back
if urlInput == "x":
return "MainMenu"

# Validate video URL and get info about video and channel
videoInfo = validation.validate_video_id(urlInput, pass_exception=True)
if videoInfo[0] == True:
validChoice = True

videoID = videoInfo[1]
videoTitle = videoInfo[2]
commentCount = videoInfo[3]
channelID = videoInfo[4]
channelTitle = videoInfo[5]

print("\nResults:")
print(f" - {F.BLUE}Video Title{S.R}: {videoTitle}")
print(f" - {F.BLUE}Channel Name{S.R}: {channelTitle}")
print(f" - {F.BLUE}Channel ID{S.R}: {B.YELLOW}{F.BLACK} {channelID} {S.R}")

input("\nPress Enter to return to main menu...")
return "MainMenu"
19 changes: 14 additions & 5 deletions YTSpammerPurge.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import Scripts.files as files
import Scripts.logging as logging
import Scripts.operations as operations
import Scripts.user_tools as user_tools
from Scripts.community_downloader import main as get_community_comments #Args = post's ID, comment limit
import Scripts.community_downloader as community_downloader
from Scripts.utils import choice
Expand Down Expand Up @@ -441,7 +442,9 @@ def primaryInstance(miscData):
print(f" 6. Create your own {F.LIGHTGREEN_EX}config file(s){S.R} to run the program with pre-set settings")
print(f" 7. Remove comments using a {F.LIGHTRED_EX}pre-existing list{S.R} or log file")
print(f" 8. Recover deleted comments using log file")
print(f" 9. Check & Download {F.LIGHTCYAN_EX}Updates{S.R}\n")
print(f" 9. Check & Download {F.LIGHTCYAN_EX}Updates{S.R}")
print(f" 10. {F.BLACK}{B.LIGHTGREEN_EX} NEW! {S.R} Helpful Tools")
print("")



Expand All @@ -452,12 +455,12 @@ def primaryInstance(miscData):
if validConfigSetting == True and config and config['scan_mode'] != 'ask':
scanMode = config['scan_mode']
else:
scanMode = input("Choice (1-9): ")
scanMode = input("Choice (1-10): ")
if scanMode.lower() == "q":
sys.exit()

# Set scanMode Variable Names
validModeValues = ['1', '2', '3', '4', '5', '6', '7', '8', '9', 'chosenvideos', 'recentvideos', 'entirechannel', 'communitypost', 'commentlist', 'recentcommunityposts']
validModeValues = ['1', '2', '3', '4', '5', '6', '7', '8', '9','10', 'chosenvideos', 'recentvideos', 'entirechannel', 'communitypost', 'commentlist', 'recentcommunityposts']
if scanMode in validModeValues:
validMode = True
if scanMode == "1" or scanMode == "chosenvideos":
Expand All @@ -478,8 +481,10 @@ def primaryInstance(miscData):
scanMode = "recoverMode"
elif scanMode == "9":
scanMode = "checkUpdates"
elif scanMode == "10":
scanMode = "tools"
else:
print(f"\nInvalid choice: {scanMode} - Enter a number from 1 to 9")
print(f"\nInvalid choice: {scanMode} - Enter a number from 1 to 10")
validConfigSetting = False

# ================================================================================= CHOSEN VIDEOS ======================================================================================================
Expand Down Expand Up @@ -931,7 +936,6 @@ def primaryInstance(miscData):
# Recove deleted comments mode
elif scanMode == "recoverMode":
result = modes.recover_deleted_comments(config)

if str(result) == "MainMenu":
return True

Expand All @@ -940,6 +944,11 @@ def primaryInstance(miscData):
if str(result) == "MainMenu":
return True

elif scanMode == "tools":
result = user_tools.user_tools_menu(config)
if str(result) == "MainMenu":
return True

# ====================================================================================================================================================================================================
# ====================================================================================================================================================================================================

Expand Down

0 comments on commit 968e0cb

Please sign in to comment.