Skip to content

Commit cc9d572

Browse files
authored
Add files via upload
1 parent fd16c52 commit cc9d572

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

_scrape.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import scrapetube
2+
import sys
3+
4+
path = '_list.txt'
5+
6+
print('**********************\n')
7+
print("The result will be saved in '_list.txt' file.")
8+
print("Enter Channel ID:")
9+
10+
# Prints the output in the console and into the '_list.txt' file.
11+
class Logger:
12+
13+
def __init__(self, filename):
14+
self.console = sys.stdout
15+
self.file = open(filename, 'w')
16+
17+
def write(self, message):
18+
self.console.write(message)
19+
self.file.write(message)
20+
21+
def flush(self):
22+
self.console.flush()
23+
self.file.flush()
24+
25+
sys.stdout = Logger(path)
26+
27+
# Strip the: "https://www.youtube.com/channel/"
28+
channel_id_input = input()
29+
channel_id = channel_id_input.strip("https://www.youtube.com/channel/")
30+
31+
videos = scrapetube.get_channel(channel_id)
32+
33+
for video in videos:
34+
print("https://www.youtube.com/watch?v="+str(video['videoId']))
35+
# print(video['videoId'])

0 commit comments

Comments
 (0)