Coder Social home page Coder Social logo

egbertbouman / youtube-comment-downloader Goto Github PK

View Code? Open in Web Editor NEW
844.0 26.0 215.0 62 KB

Simple script for downloading Youtube comments without using the Youtube API

License: MIT License

Python 100.00%
youtube-comments youtube python data-science data-scraper

youtube-comment-downloader's Introduction

youtube-comment-downloader

Simple script for downloading Youtube comments without using the Youtube API. The output is in line delimited JSON.

Installation

Preferably inside a python virtual environment install this package via:

pip install youtube-comment-downloader

Or directly from the GitHub repository:

pip install https://github.com/egbertbouman/youtube-comment-downloader/archive/master.zip

Usage as command-line interface

$ youtube-comment-downloader --help
usage: youtube-comment-downloader [--help] [--youtubeid YOUTUBEID] [--url URL] [--output OUTPUT] [--limit LIMIT] [--language LANGUAGE] [--sort SORT]

Download Youtube comments without using the Youtube API

optional arguments:
  --help, -h                             Show this help message and exit
  --youtubeid YOUTUBEID, -y YOUTUBEID    ID of Youtube video for which to download the comments
  --url URL, -u URL                      Youtube URL for which to download the comments
  --output OUTPUT, -o OUTPUT             Output filename (output format is line delimited JSON)
  --pretty, -p                           Change the output format to indented JSON
  --limit LIMIT, -l LIMIT                Limit the number of comments
  --language LANGUAGE, -a LANGUAGE       Language for Youtube generated text (e.g. en)
  --sort SORT, -s SORT                   Whether to download popular (0) or recent comments (1). Defaults to 1

For example:

youtube-comment-downloader --url https://www.youtube.com/watch?v=ScMzIvxBSi4 --output ScMzIvxBSi4.json

or using the Youtube ID:

youtube-comment-downloader --youtubeid ScMzIvxBSi4 --output ScMzIvxBSi4.json

For Youtube IDs starting with - (dash) you will need to run the script with: -y=idwithdash or --youtubeid=idwithdash

Usage as library

You can also use this script as a library. For instance, if you want to print out the 10 most popular comments for a particular Youtube video you can do the following:

from itertools import islice
from youtube_comment_downloader import *
downloader = YoutubeCommentDownloader()
comments = downloader.get_comments_from_url('https://www.youtube.com/watch?v=ScMzIvxBSi4', sort_by=SORT_BY_POPULAR)
for comment in islice(comments, 10):
    print(comment)

youtube-comment-downloader's People

Contributors

ajskateboarder avatar barbaragribeiro avatar daruko0 avatar egbertbouman avatar huyhoang8398 avatar minamotorin avatar seppeljordan avatar vizonex avatar xenova avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

youtube-comment-downloader's Issues

feature request - code to get youtube reviews in different languages

Hello, I want to thank you for this code. I've used it for my university project.

However, as an additional feature I've created a small python script "youtubeReviewsInLanguages.py" to collect the reviews in the languages other than English. If you find it okay, please add it to your code base. This python script can be used after running following command:

python3 youtube-comment-downloader/downloader.py --youtubeid <youtubeid> --output json_files/input.json

#!/usr/bin/python3

import sys
import langid
import pandas as pd

# a code by Raghvendra Pratap Singh
# M.Sc. student, Dublin City University, Ireland, 2019-20
#
#usage:
#python3 youtubeReviewsInLanguages.py <input json file> <two letter language> <output.csv>
#
#example:
#python3 youtubeReviewsInLanguages.py json_files/input.json hi outputs_dir/output.csv

jsonfileValue = sys.argv[1]

data = pd.read_json(jsonfileValue, lines=True)
df = pd.DataFrame(data)
df2 = pd.DataFrame(columns=['text'], data=df[['text']].values)
list = []
count = 0
ListOfLanguages = ['af','am','an','ar','as','az','be','bg','bn','br','bs','ca','cs','cy','da','de','dz','el','en','eo','es','et','eu','fa','fi','fo','fr','ga','gl','gu','he','hi','hr','ht','hu','hy','id','is','it','ja','jv','ka','kk','km','kn','ko','ku','ky','la','lb','lo','lt','lv','mg','mk','ml','mn','mr','ms','mt','nb','ne','nl','nn','no','oc','or','pa','pl','ps','pt','qu','ro','ru','rw','se','si','sk','sl','sq','sr','sv','sw','ta','te','th','tl','tr','ug','uk','ur','vi','vo','wa','xh','zh','zu']

if len(sys.argv[2])==2:
    if sys.argv[2] in ListOfLanguages:
        # Strips the newline character
        for index, row in df2.iterrows():
            a = langid.classify(str(row))
            if a[0]==sys.argv[2]:
                list.append(row)
    else:
        print("Please check https://pypi.org/project/langid/1.1dev/ and if your input language is available there, add it to ListOfLanguages")
else:
    print("please enter the language with length of 2 characters")
    sys.exit()


df3 = pd.DataFrame(list)
df3.to_csv(sys.argv[3], encoding='utf-8')

Note: A better approach would be to run this command through the scheduler in Linux.
It worked well for me and I've collected 5,000+ reviews in Hindi Language

Add profile image of author

Hi all!
A cool script! I want we also can crawl profile image of author. How can I do it? or How would the CSS selector look:
profile_sel = CSSSelector('.profile') ???
Thank you so much!!!

Error latin-1 codec when trying to download comments

When i try to download the comments i get an error
Error: 'latin-1' codec can't encode characters in position 1132-1134: ordinal not in range(256)
Ubuntu 16.04.7 everything is updated including the related pip packages, same problem on python3.5 and python2.7
Thanks

if the videoid starts with "-" it doesn't work

youtube-comment-downloader-master$ ./downloader.py --youtubeid -SxV944iB48
usage: downloader.py [--help] [--youtubeid YOUTUBEID] [--output OUTPUT]
downloader.py: error: argument --youtubeid/-y: expected one argument

Having trouble dealing with non-latin text.

I might be stating the problem poorly, but when downloading Japanese comments (or non-latin) they're not readable at all. Well, they are in utf-16 format (/uXXXX/uYYYYY/uZZZZ). I can convert them using a utf-16 decode site, but I'd love it if the output can be properly formatted.

You can use the youtube-id ZlyBnfiYJL0 for example to try it for yourself.

Exclude CID from output

I'm using this script to extract commentors name and profile pictures URL.
Any way to remove the CID from the output?
After my testing, it seems hard to achieve because it's required in functions.

Format issue

Thank you very much for your script. it runs nice.

I have a small issue. once it is done scraping, the format is a non json recognized format.
is there a way to parse out the information in a human readable format?

tx

sample of scrape:
{"text": "Very nice build! I actually saw this idea for the hardware on DIY Creators Murphy bed also.\ufeff", "time": "5 hours ago", "author": "BULLY TUBE", "cid": "UgwRXSS46gAhx3-FE1F4AaABAg"} {"text": "Great project brother, and you have a cute helper there who likes to look cool \ud83d\ude0e when he works.\ufeff", "time": "8 hours ago", "author": "Jason B", "cid": "Ugwc7a3DfADEjn1VJ5Z4AaABAg"} {"text": "I would have made a shallow cabinet to put stuff inside instead of floating shelves. I'm a lazy guy. I'd hate to have to take stuff off the shelves to use the bed. Great video.\ufeff", "time": "16 hours ago", "author": "altpath", "cid": "UgypCqXA0-b2fbhVcKR4AaABAg"} {"text": "awesome job!\ufeff", "time": "17 hours ago", "author": "Roomies Garage", "cid": "Ugxycx47mO7_GARHmQJ4AaABAg"} {"text": "any issues with overspray?\ufeff", "time": "19 hours ago", "author": "ERAUWeatherMan09", "cid": "UgzBs-Bvj4XS7xFbqdV4AaABAg"} {"text": "Great build! Why is the son already so much cooler than the dad?!? Lol Background chillin!\ufeff", "time": "1 day ago", "author": "symon forte", "cid": "Ugz7YcbkcD_QWlo2WGF4AaABAg"} {"text": "what about pillows? \ngreat project\ufeff", "time": "1 day ago (edited)", "author": "Badar Almshali", "cid": "UgzxIVpHiZl2bBpbqSN4AaABAg"} {"text": "\ud83d\udc4dgood job \u0639\u0645\u0644 \u062c\u0645\u064a\u0644\ufeff", "time": "2 days ago", "author": "MOSS KAM", "cid": "Ugx7APiyDCD5qZI3Y7l4AaABAg"} {"text": "\u0627\u0646\u0627 \u0627\u062d\u062a\u0631\u0645\u0643 \u0644\u0627\u0646\u0643 \u0631\u062c\u0644 \u060c \u0643\u0644 \u0627\u0644\u064a \u0627\u0634\u0648\u0641 \u0634\u063a\u0644\u0647\u0645 \u0644\u0627\u0632\u0645 \u064a\u0627 \u0642\u0637\u0648\u0647 \u0627\u0648 \u062c\u0644\u0628 \u0627\u0648 \u062d\u0645\u0627\u0631 \u064a\u062d\u0648\u0645 \u062d\u0648\u0627\u0644\u064a\u0646\u0647 \u060c \u0628\u0633 \u0627\u0646\u062a \u0648\u0644\u062f\u0643 \u0639\u0646\u062f\u0643\ufeff", "time": "2 days ago", "author": "MOSS KAM", "cid": "UgxB0ChuFgRhu2790nV4AaABAg"} {"text": "Interesting idea. not sure about the worthless shelves. I'd probably just go with the one for the support.\ufeff", "time": "2 days ago", "author": "Tim Moen", "cid": "Ugy97inHBSSf2bWjJIN4AaABAg"} {"text": "You can sleep on your design on your own.\ufeff", "time": "2 days ago", "author": "Tyler G", "cid": "Ugy97inHBSSf2bWjJIN4AaABAg.8c98H6y-sQE8cA4Qj4hDAx"} {"text": "Cool build.\n\nDoes it squeak at all?\ufeff", "time": "3 days ago", "author": "Patrik", "cid": "Ugz371TXLSOwVWj1wEx4AaABAg"} {"text": "Looks great and seems to work great as well!\ufeff", "time": "3 days ago", "author": "Maikel Versantvoort", "cid": "Ugx17ten3SjnqpIKYhN4AaABAg"} {"text": "Nice one Tyler!!\ufeff", "time": "3 days ago", "author": "JT Woodworks", "cid": "Ugy0QjxHNY16cnxeWJN4AaABAg"} {"text": "Fantastic project, Tyler! You explained everything very well, and the wood finish looks quite elegant. Plus, I love that glue squeeze-out straw trick!\ufeff", "time": "3 days ago", "author": "ode2george", "cid": "Ugw136Io5vimdTiQ5LB4AaABAg"} {"text": "Ahhhh, I can't wait until Hudson can start helping me out in the shop :) Awesome design!\ufeff", "time": "3 days ago", "author": "Mike and Lauren", "cid": "UgyCzvU0FnCl4TuC3O94AaABAg"} {"text": "+Mike and Lauren Thanks Mike! Welcome home and congrats on the new little one!\ufeff", "time": "3 days ago", "author": "Tyler G", "cid": "UgyCzvU0FnCl4TuC3O94AaABAg.8c68NiR9cBY8c6ET5ux6zd"} {"text": "Like that spray job looks like gold... LOL\ufeff", "time": "3 days ago", "author": "Robert Bryson", "cid": "Ugx3xBtgYsctclouHy14AaABAg"} {"text": "Absolutely a great video! I love how you made it very straight forward and easy to understand. I would also kill for your workshop! Great job.\ufeff", "time": "3 days ago", "author": "Gene Cavasos DIYGene", "cid": "Ugy6VxZWC_4l-nRtjR54AaABAg"} {"text": "New subscriber just added...but the problem with that design it's the shelfs. They become obsolete when you are using the bed constantly...atleast they woupd be for me\ufeff", "time": "3 days ago", "author": "epenaloza52", "cid": "Ugwb0jczLlP8RCqHj2V4AaABAg"} {"text": "+epenaloza52 You need legs and the support. Better to have shelves when and bed is up then nothing.\ufeff", "time": "3 days ago", "author": "Tyler G", "cid": "Ugwb0jczLlP8RCqHj2V4AaABAg.8c5uwS0g6P18c5xModnVpm"} {"text": "Brilliant idea to have the shelves double as legs/support for the bed! I'll try to remeber that trick for future builds ;)\ufeff", "time": "3 days ago", "author": "Made by Magnus", "cid": "UgyxbZBHwcMkC3kZ_Vd4AaABAg"} {"text": "Really nice job finish looked great and good to see the little one helping out\ufeff", "time": "3 days ago", "author": "Terence Charlesworth", "cid": "Ugxf0bGgmXZR9OB0Hyx4AaABAg"} {"text": "I really enjoyed this video, and am thinking about a murphy for my son's apartment (which was my formal livingroom). On a personal note, I am very impressed you are starting your boy off right helping in your shop and his wearing eye protection. Some folks don't really understand how important that is, and I want to compliment you on leading by example.\ufeff", "time": "4 days ago", "author": "Elleanna U", "cid": "UgwCKd48jeXqmXGk9DZ4AaABAg"} {"text": "This project looks great! Your little guy is awesome help, he's great with the shop vac! Great instructions too.\ufeff", "time": "4 days ago", "author": "Steven Kofoed", "cid": "UgxWyNt_7yUO5_jIxAR4AaABAg"} {"text": "I really like this Murphy bed. I only question about how high up the bolt is for keeping it closed. I see your wife and am wondering can she reach the latching bolt...lol\ufeff", "time": "4 days ago", "author": "Donnie Gaskill", "cid": "Ugyo7rcLykt-i_-1Red4AaABAg"} {"text": "definitely using this style of floating shelves in our bathroom remodel...as always, looks great!\ufeff", "time": "4 days ago", "author": "Brad Greenstreet", "cid": "Ugz65vEcwJp9Rj0yp_14AaABAg"} {"text": "Really nice job...\ufeff", "time": "4 days ago", "author": "Katherine Carroll", "cid": "Ugx0BccUkjtCzmjVIjZ4AaABAg"} {"text": "COOL! \ud83d\udc4d\ufeff", "time": "4 days ago", "author": "\u0422\u0430\u043b\u044f\u043d \u0424\u0435\u0434\u043e\u0441\u043e\u0432", "cid": "UgyAakWVEFEJVFW0euV4AaABAg"} {"text": "Murphy beds are just so sweet. Nice work!\ufeff", "time": "4 days ago", "author": "Hand Tool Rescue", "cid": "UgzS5e58pk4axndUW9Z4AaABAg"} {"text": "Nice creative use of the lazy Susan as hardware. I'm not sure if access would be possible, but if you used carriage bolts would the low profile heads clear the face frame?\ufeff", "time": "4 days ago", "author": "Jeremy Specce", "cid": "UgzsobN2aLi-Y-aFUiZ4AaABAg"} {"text": "Great job! Question, how easy is the sprayer and tubing to clean?\ufeff", "time": "4 days ago", "author": "BronkBuilt", "cid": "Ugz_C1SMVFi_ECNNkgB4AaABAg"} {"text": "Overall build and that finest stain finish is just amazing.\ufeff", "time": "4 days ago (edited)", "author": "Ravs Ajay", "cid": "UgxjkzpBVKjnURcZKip4AaABAg"} {"text": "Thanks fo the inexpensive and easy idea!\ufeff", "time": "4 days ago", "author": "Linda Stone", "cid": "UgxLxXK8DbB1nb401PZ4AaABAg"} {"text": "Another great job Ty. I again commend you for getting the kids involved.\ufeff", "time": "4 days ago", "author": "Dave Harrington", "cid": "UgzVRgZBQia6BVU3q1J4AaABAg"} {"text": "Thanks Dave!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgzVRgZBQia6BVU3q1J4AaABAg.8c4pAjaJcH18c4sCs2QJqy"} {"text": "Excellent project, and the mixing of stain and clear coat better; I did the same some time ago with a table top build; had very little stain left and didn\u2019t want to go out and buy more and wanted to finish the build\ufeff", "time": "4 days ago", "author": "Neil Cruz", "cid": "Ugyo_VgsUnkPx1C7XVp4AaABAg"} {"text": "Thanks for watching Neil!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "Ugyo_VgsUnkPx1C7XVp4AaABAg.8c4nA1e_w2T8c4sC-tk3BH"} {"text": "It\u2019s unbelievable super. Like\ufeff", "time": "4 days ago", "author": "Mishgan Simple", "cid": "Ugz_7vkeU7C0OClPAsx4AaABAg"} {"text": "Thanks for watching!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "Ugz_7vkeU7C0OClPAsx4AaABAg.8c4kXn8LFmw8c4sAAQyJHj"} {"text": "I got a small suggestion I think maybe you could put another bookshelf on the other side my balance it out a little better but that's all your call great job love watching your videos keep up the good work\ufeff", "time": "4 days ago", "author": "Ron EEE", "cid": "UgxcIgC7wpnvrpkkEU14AaABAg"} {"text": "Well.....I did build one but didn't take into account the light switch! (Left that part out of the video!)\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgxcIgC7wpnvrpkkEU14AaABAg.8c4IAAX6MvY8c4s9KHFbEz"} {"text": "hey tyler i added a regular door lock to my murphy bed it seems to hold pretty good https://youtu.be/MefabOA4q5c\ufeff", "time": "4 days ago", "author": "DIY Maker", "cid": "UgwA7TfE1MmyT2OFQ3t4AaABAg"} {"text": "nice tyler\ufeff", "time": "4 days ago", "author": "DIY Maker", "cid": "UgwdvcqKOFU8Z776UFB4AaABAg"} {"text": "Just wondering if you could mix like that and brush it on\ufeff", "time": "4 days ago", "author": "Martin Davis", "cid": "UgxKFEx-AB2Y94igtJ94AaABAg"} {"text": "Probably but like I mentioned.....careful placement is important because if you overlap it makes the color darker.\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgxKFEx-AB2Y94igtJ94AaABAg.8c3tpbxtqgr8c4s3VWvrZO"} {"text": "LOL @the out of date GED prep book everyone always keeps. Some light reading for your guests.\ufeff", "time": "4 days ago", "author": "Trevor Even", "cid": "UgwDbt6MToz2FnJcUgx4AaABAg"} {"text": "Great job Tyler, you have inspired me to build bunk beds for my two grandsons on your other video which I thought was fantastic. I really like this idea for temporary bed service for guests and your room is back to normal when they leave. \nGood stuff, love it.\nAl\ufeff", "time": "4 days ago", "author": "chipshot442", "cid": "UgzuTmkmAVK6SvjLwLB4AaABAg"} {"text": "Use it and then hide it! Thanks for watching Al!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgzuTmkmAVK6SvjLwLB4AaABAg.8c3squx--qF8c4ryVEv14I"} {"text": "Great build man. Nice, straight forward, cost effective. I really want to build a queen size Murphy at some point. Thanks for the inspiration and the tips!\ufeff", "time": "4 days ago", "author": "Chris Harpster", "cid": "Ugx_-Vo79FMHhzeZ1fN4AaABAg"} {"text": "Thanks for watching Chris!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "Ugx_-Vo79FMHhzeZ1fN4AaABAg.8c3sJFw9nns8c4rw-6KHJ0"} {"text": "Hi Tyler, Great build. Did you add any more coats of finish after the stain/finish mix first coat? or was the one coat enough?\ufeff", "time": "4 days ago", "author": "VirginiaWoodsmiths", "cid": "UgwpZxYkMIXGPo_PkX54AaABAg"} {"text": "I sprayed two coats with the tint and a third clear coat over the top.\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgwpZxYkMIXGPo_PkX54AaABAg.8c3sDXCjWuO8c4rhTaavrn"} {"text": "You had 2 mistakes, the second one was you didn't have a cap on in the room, but noticed you corrected that quickly. Nice build!\ufeff", "time": "4 days ago", "author": "Harki Dodia", "cid": "Ugzk9l6vbaLEYB9sLLB4AaABAg"} {"text": "+Harki Dodia Lol! Happens when you forget it outside!! Thanks for watching!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "Ugzk9l6vbaLEYB9sLLB4AaABAg.8c3p1cOGTFf8c3qtf0jkv5"} {"text": "Great video! Just like most of them. Your channel is one I keep an eye on.\ufeff", "time": "4 days ago", "author": "rich hubert", "cid": "UgwKXAnF85Z6JGY_f8R4AaABAg"} {"text": "+rich hubert Thanks for the support Rich!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgwKXAnF85Z6JGY_f8R4AaABAg.8c3fn3iBeqJ8c3qpM36Fal"} {"text": "Great job Tyler! That looks fantastic. I especially like the idea of mixing the stain and clear coat. \nKeep up the great work \n\nThanks for sharing\ufeff", "time": "4 days ago", "author": "Roy Wrenn", "cid": "UgzsvGvGJFhtovSC8BJ4AaABAg"} {"text": "+Roy Wrenn Saves a TON of time! Thanks for watching Roy!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgzsvGvGJFhtovSC8BJ4AaABAg.8c3bver-wiU8c3qmlWJNUE"} {"text": "Cool solution. I know it doesn\u2019t have the spring to hold it upright like some of the kits, but it is not much harder to put a couple of bolts in like your design. Nice job!\ufeff", "time": "4 days ago", "author": "Bruce A. Ulrich", "cid": "UgzpUkRFBNKoAqpfzit4AaABAg"} {"text": "+Bruce A. Ulrich Good to hear, Thanks for watching!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgzpUkRFBNKoAqpfzit4AaABAg.8c3Z_SpBPjc8c3qjpGjV7v"} {"text": "Looks good!\ufeff", "time": "4 days ago", "author": "Mortgage & Mitre", "cid": "Ugyac5IAvBVglJWCMDt4AaABAg"} {"text": "+Mortgage & Mitre Thanks for watching!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "Ugyac5IAvBVglJWCMDt4AaABAg.8c3Xveaojmu8c3qgr6Gf_9"} {"text": "Nice build, Tyler! It looks great!!\ufeff", "time": "4 days ago", "author": "KSFWG", "cid": "Ugwv2JDAp07f_xdp-Tp4AaABAg"} {"text": "+KSFWG Thanks Dave!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "Ugwv2JDAp07f_xdp-Tp4AaABAg.8c3VJ0Vz-tL8c3qfkgpEDh"} {"text": "Great project. Another cheap option for coloring clear water-based finishes is just throw some instant coffee in it. Did this a while back with a project covered in red oak plywood. Thru a trial and error process, I found best trick was to dissolve a large amount of coffee crystals in a cup of hot water, then add this to the water poly. Do a bit at a time as you can always darken it but can't go back. Made a great golden-oak finish, and subsequent coats darken the finish, but recoating can make for dark streaks in the corners, so once the desired color is achieved, additional finish coats should be clear coats.\ufeff", "time": "4 days ago", "author": "gjforeman", "cid": "UgyO-_O1HzmjGwB0w_J4AaABAg"} {"text": "+gjforeman That sounds delicious! Thanks for the tip!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgyO-_O1HzmjGwB0w_J4AaABAg.8c3VHdE3l5Q8c3qeddn815"} {"text": "Tyler G Not sure how it would taste, but if you're a coffee person it smells great while drying.\ufeff", "time": "4 days ago", "author": "gjforeman", "cid": "UgyO-_O1HzmjGwB0w_J4AaABAg.8c3VHdE3l5Q8c5RKVHTlyA"} {"text": "Awesome job Tyler! \ud83d\udc4d\ud83d\udc4a\ufeff", "time": "4 days ago", "author": "Fred McIntyre", "cid": "UgwG-_H76ElZ6YeI-Hx4AaABAg"} {"text": "+Fred McIntyre Thanks Fred!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgwG-_H76ElZ6YeI-Hx4AaABAg.8c3V-Oxrgik8c3qbm9KtKt"} {"text": "Do the plans cover other sized mattresses? I'm about to build a murphy bed for a king size and would love to not spend so much $$ on the premade kits\ufeff", "time": "4 days ago", "author": "Brian Nelson", "cid": "UgwfFtYs-qZh1Y-NnDN4AaABAg"} {"text": "Nice video Tyler! Thanks for sharing.\ud83d\ude0e\ud83d\udc4dJP\ufeff", "time": "4 days ago", "author": "Jp's Custom Woodworking", "cid": "UgyQf_HU9x8rbzSTynt4AaABAg"} {"text": "+Jp's Custom Woodworking Thanks Jp!!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgyQf_HU9x8rbzSTynt4AaABAg.8c3S8hu4YHz8c3qZVmpyoE"} {"text": "You're very welcome Tyler \ud83d\ude0e\ufeff", "time": "4 days ago", "author": "Jp's Custom Woodworking", "cid": "UgyQf_HU9x8rbzSTynt4AaABAg.8c3S8hu4YHz8c3zrryBpwT"} {"text": "Isn\u2019t that a concept from DIY Creators ?\ufeff", "time": "4 days ago", "author": "Maxime Boissonneault", "cid": "Ugz9t0Fk017PTdHczxt4AaABAg"} {"text": "+Maxime Boissonneault Similar hardware, different design.....although Murphy beds can't get that much different.\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "Ugz9t0Fk017PTdHczxt4AaABAg.8c3QYuFzWVu8c3qXcw_Xq7"} {"text": "Thanks for the project. It's a refreshing new design.\ufeff", "time": "4 days ago", "author": "Tim Bowman", "cid": "UgwPkVWYjitsQXYo2fF4AaABAg"} {"text": "+Tim Bowman Thanks for watching!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgwPkVWYjitsQXYo2fF4AaABAg.8c3OeZchxpN8c3qSgH2f6Z"} {"text": "Hey, Tyler. \u00a0I thought the shelves were overkill or unnecessary until I realized you built them to serve as the legs when the bed is down. \u00a0Nice design and great solution.\ufeff", "time": "4 days ago", "author": "Mike Dixon", "cid": "UgxMssrCqyO3unN-iBx4AaABAg"} {"text": "+Mike Dixon Nice and sturdy this way. Thanks for watching!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgxMssrCqyO3unN-iBx4AaABAg.8c3MWdm2_Fo8c3qRV9gVh0"} {"text": "Awesome Tyler, keepum comin !!!\ufeff", "time": "4 days ago", "author": "Mike Neuhaus", "cid": "UgywyMoyUrlw5zlcTBF4AaABAg"} {"text": "+Mike Neuhaus Thanks Mike!!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgywyMoyUrlw5zlcTBF4AaABAg.8c3LNI3ktkg8c3qP-g0NYa"} {"text": "Very nice! Thanks for the video!\ufeff", "time": "4 days ago", "author": "Michael Coghill", "cid": "UgwO-5wyPxqMVa5KaMJ4AaABAg"} {"text": "+Michael Coghill Thanks for watching!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgwO-5wyPxqMVa5KaMJ4AaABAg.8c3KHqT92AC8c3qNNCBufR"} {"text": "EXCELLENT, SUPERB and PROFESSIONALLY Built my friend!! I certainly have the utmost respect for someone who does not edit out an \"overlook\". GREAT JOB and Video, Tyler.\ufeff", "time": "4 days ago", "author": "Orange Rocket", "cid": "Ugzbm-lz1VGQWuig1oZ4AaABAg"} {"text": "+Orange Rocket Good to hear, Thanks for watching!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "Ugzbm-lz1VGQWuig1oZ4AaABAg.8c3K2Gmz5ho8c3qMG7qpPM"} {"text": "I love the idea but my wife does not. I was thinking of building something like that for my sons room.\ufeff", "time": "4 days ago", "author": "Franks DIY", "cid": "UgzgCo7JUngItQ04h0R4AaABAg"} {"text": "+Franks DIY A man.....gotta find a good negotiating point man!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgzgCo7JUngItQ04h0R4AaABAg.8c3JmL_O8Un8c3qJRDYIsI"} {"text": "Nice job..My first table saw was a circular saw bolted from underneath. Now THAT made me nervous. :)\nThe little \"mistake\" didn't even show in the end, came out awesome..\ufeff", "time": "4 days ago", "author": "Path in AZ", "cid": "UgzMwDME6WmPjAS91Tp4AaABAg"} {"text": "+Path in AZ That would be terrifying! Thanks for watching!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgzMwDME6WmPjAS91Tp4AaABAg.8c3ItoFDMBD8c3qFvVdZvx"} {"text": "They call that the suicide saw for a reason.\ufeff", "time": "1 day ago", "author": "Phil'd With Malice", "cid": "UgzMwDME6WmPjAS91Tp4AaABAg.8c3ItoFDMBD8cBCdVLiiNm"} {"text": "nice build Tyler. Question...I am considering a murphy bed in our new home. Do you think it is possible to mount a tv to the bed so that when it is folded up you can watch tv? Thanks for any advice and thanks for making these videos.\ufeff", "time": "4 days ago", "author": "Garrett Welfare", "cid": "Ugz5Wpx5X2YpBfvT23h4AaABAg"} {"text": "Garrett Welfare, due to window placement, my thought has been to build one that pivots on a long side, rather than the head. Allowing for a shorter cabinet that fits under my odd window. Might that be enough to hang a TV?\ufeff", "time": "4 days ago", "author": "Tonia Roberts", "cid": "Ugz5Wpx5X2YpBfvT23h4AaABAg.8c3IFS_8EPJ8c3RfJ7WtsD"} {"text": "+Garrett Welfare I am not sure that the tv would be able to supports itself hanging from the back like that. Different forces compared to haging vertical. Can always test and see. Murphy bed won't care what's on there!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "Ugz5Wpx5X2YpBfvT23h4AaABAg.8c3IFS_8EPJ8c3qD8mn60u"} {"text": "that was my concern too. I know that the tv mounts have the hooks at the top, and the set screws at the bottom which keep it stable, but I am not sure if the vertical force when rotated 90 degrees is too much for the set screws to hold. Thanks for your response and great videos. I have learned a few tricks from them.\ufeff", "time": "4 days ago", "author": "Garrett Welfare", "cid": "Ugz5Wpx5X2YpBfvT23h4AaABAg.8c3IFS_8EPJ8c5MvvgxgZi"} {"text": "Nice build! What is that I see, another one on the way? Congrats! Better build some more beds!\ufeff", "time": "4 days ago", "author": "Kyle Veatch", "cid": "UgxG_3UWThsDhMQ9GGJ4AaABAg"} {"text": "+Kyle Veatch Sharp eye! Thanks, more bunk beds on the way!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgxG_3UWThsDhMQ9GGJ4AaABAg.8c3FAOtXSo28c3q2B_PzvM"} {"text": "Nice job buddy. But far away from professional woodworking . Sorry bro\ufeff", "time": "4 days ago", "author": "hank iven", "cid": "UgwGj2W3Hqq5giIdtkx4AaABAg"} {"text": "+hank iven Don't see your point. Never claim to be a pro...my brand is DIY.\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgwGj2W3Hqq5giIdtkx4AaABAg.8c3EMtfsZbQ8c3FZijUAox"} {"text": "One cool upcoming woodworker at 4:06 and at 9:26 showing some great cleanup skills. Great project as always Ty, and that Fuji sprayer sure looked awsome. Is the overspray really so minimal that no covering is needed in the shop?\ufeff", "time": "4 days ago", "author": "Bellevue Woodshop", "cid": "Ugy2vaTYaOM_R6a7BmJ4AaABAg"} {"text": "+Bellevue Woodshop It is if you go slow with a lower spray feed. But, shooting only a clear water based top coat I think the finish is dried by the time it lands on anything besides the project. Haven't noticed any Ill effects. Thanks for watching Roy, hope all had been well across the pond.\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "Ugy2vaTYaOM_R6a7BmJ4AaABAg.8c3EL8uyqvl8c3pzyRrvyV"} {"text": "Muy Bueno el proyecto \nPara cuando tienes pocos espacios.\nFelicidades.\ufeff", "time": "4 days ago", "author": "Lorenzo Gonzalez", "cid": "UgybwAHg1uxVcN5Gml54AaABAg"} {"text": "What? A youtube bed project not sponsored by Casper? Isn't that against the rules? (Looks great!)\ufeff", "time": "4 days ago", "author": "Toby Kathan", "cid": "Ugy1k3Y5zjiaYYUO4RJ4AaABAg"} {"text": "+Toby Kathan lol! Not this time! Thanks for watching!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "Ugy1k3Y5zjiaYYUO4RJ4AaABAg.8c3D3OwT2K08c3po3lLsZq"} {"text": "Maybe it's just my screen, but the white balance seems awfully high in this video.\ufeff", "time": "4 days ago", "author": "B.Gilly", "cid": "Ugxe9UqjOFmkQrnXQaR4AaABAg"} {"text": "+B.Gilly When I jump from inside to out the shop seems very bright. No change in settings.\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "Ugxe9UqjOFmkQrnXQaR4AaABAg.8c3Ag7b2Z-m8c3plRwm90D"} {"text": "Very nice build and what a great finishing..?\ufeff", "time": "4 days ago", "author": "Stamatis T", "cid": "UgxZ7Zmhq_SNksEq9zh4AaABAg"} {"text": "+Stamatis T Thanks man, super pleased with the finish!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgxZ7Zmhq_SNksEq9zh4AaABAg.8c3A3WXmtEE8c3pgBoM4mo"} {"text": "Great project, super build. Is the purpose of this bed to be in the guest room and not used often?\ufeff", "time": "4 days ago", "author": "Paulina Paulino", "cid": "UgyaLHazPMooF3Y4zJ54AaABAg"} {"text": "+Paulina Paulino Yes, it will be used very rarely...3-4 times a year maybe. Thanks for watching!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgyaLHazPMooF3Y4zJ54AaABAg.8c39we4FiEo8c3pdIeS_j7"} {"text": "Great Tyler \ud83d\udc4f\ud83d\udc4f\ud83d\udc4f\ud83d\udc4f\ud83d\udc4f\ud83d\udc4f\ufeff", "time": "4 days ago", "author": "giovanni petitti", "cid": "UgwuBg24wIGtDomGYq14AaABAg"} {"text": "+giovanni petitti Thank you!!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgwuBg24wIGtDomGYq14AaABAg.8c39dURBDyf8c3pYoPyv50"} {"text": "Great video Tyler\ufeff", "time": "5 days ago", "author": "Leo Braceday", "cid": "UgzqbMLPoxhlviIIrrF4AaABAg"} {"text": "+Leo Braceday Thanks!\ufeff", "time": "4 days ago", "author": "Tyler G", "cid": "UgzqbMLPoxhlviIIrrF4AaABAg.8c382GB3uFp8c3pXG6-ln-"}

Missing Authorid

Hey!

I'm not sure when the authorid fell off but it must have happened during a PR.

(New API)
'authorid': comment['authorEndpoint']['browseEndpoint']['browseId'],

(Old API)
'authorid': author_sel(item)[0].attrib['href'].replace('/channel/','').strip(),

Maybe the "votes" field is not right when it is zero in `download_comments_old_api`

When using download_comments_old_api, there is no zero votes in comment list.
There are 2 elements with class like-count: they are
class="like-count on" and class="like-count off”, and "like-count on" = "like-count off" + 1.

Note that, when real votes is zero, element class="like-count off" doesn't exist.

So here is how I make it work:
I change the code in extract_comments to
vote_sel = CSSSelector('.like-count') -> vote_sel = CSSSelector('.like-count.off')
'votes': vote_sel(item)[0].text_content() -> 'votes': vote_sel(item)[0].text_content() if len(vote_sel(item)) > 0 else 0,

Recently i'm getting Error: write() argument 1 must be unicode, not str

The script was working great, a few weeks ago i started getting the error
Error: write() argument 1 must be unicode, not str

I'm doing ./downloader.py --youtubeid uE89Tzd3Ajk --output /tmp/comments

Downloading Youtube comments for video: uE89Tzd3Ajk
Error: write() argument 1 must be unicode, not str

tested on ubuntu 16.04 python 2.7.12

Any ideas?
Thanks

I just tried with python3.5 it still works.

Help

Please this in write in java

License questions

Would it be possible to relicense this under the Unlicense so it could be used in youtube-dl?

Python 2.x Print vs 3.x Print

I am in no way a python expert, nor have I ever written my own script, but you claim that your script is 2.7+ capable and I don't think that's the case. I'm sure that doesn't only mean 2.x variants, but could be wrong.

Believed to have confirmed my guess as:

  File "downloader.py", line 144
    print 'Downloading Youtube comments for video:', youtube_id
                                                  ^
SyntaxError: invalid syntax

EDIT: works great on 2.7! Thanks!

Also I tried updating print to 3.x syntax and it appears there is more than print being the problem. Is it possible to make a script that reads user python version and acts accordingly?

Socks version error on Ubuntu after running under a LAN with proxy

Hi,

After running the code, I am getting below error.

ajit@ajit-desktop:~/Downloads/youtube-comment-downloader-master$ python downloader.py --youtubeid YykjpeuMNEk --output comments
Downloading Youtube comments for video: YykjpeuMNEk
Error: Unable to determine SOCKS version from socks://10.10.80.11:3128/

Can you please, tell what is wrong in running the code.

Thanking You.

With Regards.

Can I download comments from multiple channels and all videos in those channels?

I use YouTube-DL to run a single batch file which downloads all the videos from multiple channels specified in the batch file. Videos are downloaded into automatically named directories like this:

C:\YouTubeDL\Channel_Name\Video_Title\DateUploaded. Video_Title VideoID.mp4

Does your program allow me to run a single script to download all comments on all videos from several different channels?
If so, how do I do that?

Can I have each of the comments file download into a different directory like the above example? So the comment file will go into the directory created by YouTubeDL.

Thanks

"Error: generator raised StopIteration" with videos that have info panel

I tried to run the script for a live stream (id = TcevjiHMz8I) which has the COVID-19 info panel and it happens that the code searches for itemSectionRenderer to find the continuations, but for this type of video there are two itemSectionRenderer and the one with the continuations is the second one.
This leads to "Error: generator raised StopIteration" when the script calls next() to the generator created when searching for nextContinuationData inside the renderer, since there is none.

UnicodeEncodeError

https://youtu.be/qFrbmseX9TI
When you try to download comments on archived livestreams, when you run the code in Python 2.7, an error occurs

Traceback (most recent call last):
  File "downloader.py", line 244, in <module>
    main(sys.argv[1:])
  File "downloader.py", line 239, in main
    print('Error:', str(e))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 28-38: ordinal not in range(128)

The tags

Im wondering about how to find those css tags? I want to crawl the like data

Error: Expecting value: line 1 column 1 (char 0)

Here is the error
Error: Expecting value: line 1 column 1 (char 0)

I checked the program. It seems that
in def extract_comments(html):

tree = lxml.html.fromstring(html)

returns empty content.

and the following line is not working, popping up Error: Expecting value: line 1 column 1 (char 0)
for item in item_sel(tree):

Please take a look. Thanks.

It's nice script.

First of all thanks you for the script. I come here from github search. Is there anyway I can return the result from a method instead of returning it in a file.

Adding Comments Likes

Hi
Awesome script! How would the CSS selector look if I were to add one for extracting the number of likes?

lately the script seems to hang on downloading comments intermittently

Lately, the script seems to hang on downloading the comments, it's intermittent as i can download the comments fully on the same video other times.
I'm currently trying to log the errors to get any feedback, might run with strace if nothing shows up, all i see now is the process in "ps" and comments not fully downloaded.

Integrate this with youtube-dl?

Hello, I very much like your program, but would love if it was integrated into youtube-dl as youtube-dl is currently lacking in any feature to download comments.

My specific use case is I download Youtube channels using Youtube-dl but would also like to also have the comments downloaded. Is there anyway for me to do this is some kind of automated way using youtube-dl and your script?

Thanks and hope to hear back from you!

Limit to an amount of comments

The scrapper is great but I feel it lacks the ability to take in a number representing the MAX amount of comments it should extract. I believe this is something not too difficult to implement and would be very useful since some videos can have thousands of comments and the extraction takes too long.

Thanks and keep up the good work!

Small bug with bold char.

In the live video portion, if the code comes across anything bold in the comment it will wrap up the comment as if it hit the end.

YouTube link:
https://www.youtube.com/watch?v=FBCLNEDq1D0

Example:
image

The script returns:
"Viv, buddy. If you are going to continue with these "Live Chats", then you "

I'll try to look for a fix. My assumption is that because it creates a different HTML-tag, then the script doesn't recognize it.

image

Can I grab all the comments of several videos at once?

Hello,
First thanks for the code, it works!
Since I am a beginner of Python and I would like to download comments of 80 videos. (I have already made the list of the ids.)
I am wandering Is it possible to download all of them at once and add video id in the output which looks like:
{"video id": -----, "cid":------, "text":-------, etc)
I guess maybe this can be deal with for loop...?

I'll really appreciate if someone can help me.
Thank you!

Extract author's channel ID

Why not to extract author's channel ID?

Just add
'channel': item[0].get('href'),
in the loop of extract_comments function

How to get youtube comment timestamp?

I am trying to get the comment timestamp instead of "2 days ago".

Because of youtube api limit ,I can not use it to get comments.

So what should I do?

Thks for all : )

Ability to sort comments by rating

By default the script extracts newest comments first. It lacks the option to sort comments by rating - Top comments first.
As it is not always possible to get rating by the number of likes.

Script Hangs On Uploads That Were Live

So I recently discovered a strange issue. When channel uploads a video that used to be live (not while it is live, but after) the script hangs. I can't quite figure out what changed. There are clearly existing comments, but the script is unable to grab them.

Here is a video example:
https://www.youtube.com/watch?v=zCgDnMhd4yA

Could it possibly have something to do with the page_tokens? The initial top section of the download_comments function works, and I can get a printout, but once it jumps into the while page_token loop, I can no longer get a return from a standard "print()" method.

Any guesses?

Comments on archived livestreams are not being downloaded

This issue only affects archived livestreams, comments on normal videos will be downloaded without a hitch.

Steps to reproduce:

  1. Find an archived livestream
  2. Download comments using YouTube comment downloader
  3. YouTube comment downloader finishes without downloading any comments

SyntaxError: invalid syntax

When running with $ python downloader.py

  File "downloader.py", line 98
    yield from search_dict(v, key)
             ^
SyntaxError: invalid syntax

When running with $ python3 downloader.py no error.
Ubuntu 16.04 64-bit, Git revision 9194bf8
Need to make a change to Usage.

A little confused.

The code works amazingly! But I don't understand how it's finding these selectors. When I inspect a video, I don't see the selectors. Especially '.user-name'. The other ones don't have exact matches and include 'renderer' in the name. Would you please explain how it works? Thank you!

def extract_comments(html): tree = lxml.html.fromstring(html) item_sel = CSSSelector('.comment-item') text_sel = CSSSelector('.comment-text-content') time_sel = CSSSelector('.time') author_sel = CSSSelector('.user-name')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.