Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ZG4RBU committed Nov 29, 2023
1 parent 6006eab commit 263df37
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
15 changes: 11 additions & 4 deletions archiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from archiver_packages.htmls import ending
from archiver_packages.utilities.utilities import del_special_chars, convert_date_format, list_files_by_creation_date
from archiver_packages.utilities.selenium_utils import chrome_setup
from archiver_packages.utilities.youtube_utils import download_videos_with_info, get_youtube_links_from_playlist, input_youtube_links
from archiver_packages.utilities.youtube_utils import download_videos_with_info, get_youtube_links_from_playlist_and_channel, input_youtube_links
from archiver_packages.utilities.archiver_utils import remove_output_folder, chrome_version_exception


Expand Down Expand Up @@ -113,19 +113,26 @@ def archiver(yt_urls:list,output_directory:str="downloaded"):
input("\nMega.io login credentials not found. Please enter them in settings.json")

remove_output_folder(output_directory)

print("\nDownloading videos...")

# Extract yt urls from playlists
# Extract yt urls from playlists and channels
for yt_url in yt_urls:
if "&list=" in yt_url:
extracted_urls = get_youtube_links_from_playlist(yt_url)
extracted_urls = get_youtube_links_from_playlist_and_channel(yt_url)
yt_urls.remove(yt_url)
yt_urls.extend(extracted_urls)
elif "/@" in yt_url:
extracted_urls = get_youtube_links_from_playlist_and_channel(yt_url)
yt_urls.remove(yt_url)
yt_urls.extend(extracted_urls)

# Download yt videos and extract metadata
info_list = download_videos_with_info(yt_urls,output_directory)

print(f"YouTube urls: {len(yt_urls)}")
print(f"Metadata: {len(info_list)}")

# Load chromedriver
try:
driver = chrome_setup(
Expand Down
6 changes: 3 additions & 3 deletions archiver_packages/mega.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ def mega_upload(driver:webdriver.Chrome,login:str,password:str,delay:int,files:l
else:
WebDriverWait(driver, 60**2*5, poll_frequency=20).until(EC.visibility_of_element_located((By.XPATH, "//div[@class='transfer-progress-txt' and text()='Completed']")))

# Select file
file = driver.find_element(By.XPATH, f"//span[@class='tranfer-filetype-txt' and text()='{filepath.name}']/parent::*/ancestor::tr")
# Select file on mega
mega_file = driver.find_element(By.XPATH, f'//span[@class="tranfer-filetype-txt" and text()="{filepath.name}"]/parent::*/ancestor::tr')
act=ActionChains(driver)
act.move_to_element(file).click().perform()
act.move_to_element(mega_file).click().perform()

# Click on get link button
sleep(delay+1)
Expand Down
6 changes: 3 additions & 3 deletions archiver_packages/utilities/youtube_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ def input_youtube_links() -> list[str]:
try:
while True:
print("\nNOTE:")
print("Add YouTube Videos/Playlists one by one. Finally type 'S/s' to start")
print("Add YouTube Video/Playlist/Channel URLs one by one. Finally type 'S/s' to start")
link = input("\n >> Add YouTube link: ")

if link.lower()=='s':
break
if link not in yt_links: # Avoid duplicates
yt_links.append(link)

#print Full list
# Print Full list
clear()
print("Author\t Title\t Link\t")

Expand All @@ -55,7 +55,7 @@ def input_youtube_links() -> list[str]:
return yt_links


def get_youtube_links_from_playlist(playlist_link:str) -> list[str]:
def get_youtube_links_from_playlist_and_channel(playlist_link:str) -> list[str]:

with yt_dlp.YoutubeDL() as ydl:
playlist_dict = ydl.extract_info(playlist_link, download=False)
Expand Down

0 comments on commit 263df37

Please sign in to comment.