shailshouryya / yt-videos-list

Create and **automatically** update a list of all videos on a YouTube channel (in txt/csv/md form) via YouTube bot with end-to-end web scraping - no API tokens required. Multi-threaded support for YouTube videos list updates.
Apache License 2.0
107 stars 20 forks source link

Print links instead of saving to file #12

Closed iskrenpanteleev closed 3 years ago

iskrenpanteleev commented 3 years ago

First of all, thank you for your package and contribution. May I ask if it's possible somehow to print the scraped channel videos instead of saving them to a file? Best regards.

shailshouryya commented 3 years ago

Hey, sure thing, that should be possible!

I'm assuming you want something like this (in the reverse_chronological=True format):

Video Number: 99
Video Title:  Title 99 by Channel
Vide URL:     https://youtube.com/watch?v=SOME_CHARS99

Video Number: 98
Video Title:  Title 98 by Channel
Vide URL:     https://youtube.com/watch?v=SOME_CHARS98

Video Number: 97
Video Title:  Title 97 by Channel
Vide URL:     https://youtube.com/watch?v=SOME_CHARS97

or like this (in the reverse_chronological=False format):

Video Number: 1
Video Title:  Title 1 by Channel
Vide URL:     https://youtube.com/watch?v=SOME_CHARS1

Video Number: 2
Video Title:  Title 2 by Channel
Vide URL:     https://youtube.com/watch?v=SOME_CHARS2

Video Number: 3
Video Title:  Title 3 by Channel
Vide URL:     https://youtube.com/watch?v=SOME_CHARS3

Is this along the lines of what you're looking for, or were you thinking of something else?

Also, rather than modifying the program, would something such as the following work?

If you're on a Linux/Unix based machine (such as a Mac), something like this:

import os
from yt_videos_list import ListCreator

lc = ListCreator(csv=False, md=False)
channel_name = lc.create_list_for(url='CHANNEL_URL')
os.system(f'cat {channel_name}.txt && rm {channel_name}.txt')

If you're on Windows, something like this:

import os
from yt_videos_list import ListCreator

lc = ListCreator(csv=False, md=False)
channel_name = lc.create_list_for(url='CHANNEL_URL')
os.system(f'type {channel_name}.txt && del {channel_name}.txt')

This is probably the simplest solution! A short explanation:

If this won't work for your use case, or you want to get rid of the following part of the file:

Watched?

Watch again later?

Notes:

***************************************************************************

then we can add a function in the program.py and create_file.py submodules to do this, but that'll be a bit more involved - I can add this feature over the next few days if you'd like that! 🙂

shailshouryya commented 3 years ago

Formal support for this included with release v0.6.1.

To return the video data to terminal directly WITHOUT saving to any output files, you can use the following:

from yt_videos_list import ListCreator
lc = ListCreator(txt=False, csv=False, md=False, all_video_data_in_memory=True, video_data_returned=True)

your_url = 'youtube.com/some/channel'

video_data, channel_info = lc.create_list_for(url=your_url)

for video in video_data:
    print(video)

This will allow you to see all the video data for a specific channel in your terminal without saving to a file. See the documentation for more information (the release notes provide more details on how to access the relevant documentation).

shailshouryya commented 3 years ago

Closing this issue due to inactivity and because a solution to the problem was initially provided as a temporary workaround, and then included in the package using a more elegant implementation.

Please reopen this issue if something stops working (or does not work), or if something else comes up!