Skip to content

Commit 3b159c4

Browse files
authored
Update documentation to include new features & usage (#65)
1 parent 081b88b commit 3b159c4

File tree

1 file changed

+39
-28
lines changed

1 file changed

+39
-28
lines changed

README.md

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,55 +27,66 @@ each comment.
2727
well.
2828
5. Create a file in the `/src` directory called `.env`. This file should contain
2929
The following values:
30-
```
30+
```
3131
API_KEY=<key> # your YouTube Data API key
3232
DB_FILE=<filename> # the database file to which collected data will be written
3333
LOG_LEVEL=[debug|info|warn|error]
3434
```
3535
For information about how to create an API key, see [here](https://blog.hubspot.com/website/how-to-get-youtube-api-key).
3636
37-
Alternatively, these values can be passed to Astro on the command line. See
38-
the help menu below for more information.
39-
```
40-
(astro) $ python astro.py -h
41-
usage: astro.py [-h] [-l {debug,info,warn,error}] [--api-key API_KEY] [--db-file DB_FILE] youtube_url
37+
Alternatively, these values can be passed to Astro on the command line. See
38+
the help menu below for more information.
39+
```
40+
(astro) $ python astro.py --help
41+
Usage: astro.py [-h] [-l {debug,info,warn,error}] [--api-key API_KEY] [--db-file DB_FILE] [--log-file LOG_FILE]
42+
[-j | --log-json | --no-log-json]
43+
youtube_url
44+
45+
A tool for YouTube data collection.
4246
43-
positional arguments:
47+
Positional Arguments:
4448
youtube_url youtube video URL
4549
46-
options:
50+
Options:
4751
-h, --help show this help message and exit
48-
-l {debug,info,warn,error}, --log {debug,info,warn,error}
49-
Set the logging level
50-
--api-key API_KEY YouTube Data API key
51-
--db-file DB_FILE database filename
52+
-l, --log {debug,info,warn,error}
53+
Set the logging level (default: info)
54+
--api-key API_KEY YouTube Data API key (default: None)
55+
--db-file DB_FILE database filename (default: astro.db)
56+
--log-file LOG_FILE log output to specified file (default: astro_log.txt)
57+
-j, --log-json, --no-log-json
58+
log json API responses (default: False)
5259
```
5360
6. Run the tool with `python astro.py <YouTube video URL>` to start collecting
5461
data. You can see output from an example run in the next section.
5562
5663
## Example
57-
This output below was generated by providing the video ID string of a relatively
58-
small YouTube channel.
64+
This output below was generated using a YouTube video URL from user 'hbomberguy'.
5965
```
60-
(astro) $ python astro.py 'https://www.youtube.com/watch?v=HthY7qxV8q0' -l debug --api-key <key> --db-file astro.db
61-
INFO:__init__.py:autodetect: file_cache is only supported with oauth2client<4.0.0
62-
DEBUG:discovery.py:method: URL being requested: GET https://youtube.googleapis.com/youtube/v3/commentThreads?part=snippet%2Creplies&videoId=HthY7qxV8q0&textFormat=plainText&key=<...>&alt=json
63-
DEBUG:astro.py:main: Collected data preview:
64-
comment user date PSentiment NSentiment
65-
0 tbh ur voice is so relaxing i love it @johan2380 2024-09-25T21:34:21Z 0.0 0.0
66-
1 Giant keys dorp twice as often in the wilderne... @selkokieli843 2024-09-23T19:06:29Z 0.0 0.25
67-
2 Dorp lol @Nakedlollipop 2024-09-24T02:04:58Z 0.0 0.0
68-
3 wilderness is the way to go here. cannon isnt ... @breaddboy 2024-09-23T18:46:20Z 0.0 0.125
69-
4 The description is about mossy keys and Bryoph... @MrRXY11 2024-09-23T16:49:55Z 0.0 0.0
70-
5 no it's not you're crazy. gaslighting isn't re... @Spookdog 2024-09-23T19:18:19Z 0.0 0.625
71-
6 Easier way imo is in the giants den with a zar... @jakeparkinson9639 2024-09-23T16:32:56Z 0.0 0.0
72-
7 First @HeyItsVarn 2024-09-23T16:05:07Z 0.0 0.0
66+
(astro) $ python astro.py 'https://www.youtube.com/watch?v=0twDETh6QaI'
67+
[10/26/24 11:56:52] INFO video_id: 0twDETh6QaI log.py:119
68+
INFO video_title: ROBLOX_OOF.mp3 log.py:119
69+
INFO channel_id: UClt01z1wHHT7c5lKcU8pxRQ log.py:119
70+
INFO channel_title: hbomberguy log.py:119
71+
INFO view_count: 13852769 log.py:119
72+
INFO like_count: 398474 log.py:119
73+
INFO comment_count: 46258 log.py:119
74+
INFO comments_disabled: False log.py:119
75+
Downloading comments 100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 46258/46258 • 0:03:02 • 0:00:00
76+
Calculating comment sentiment 100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 39643/39643 • 0:00:53 • 0:00:00
77+
[10/26/24 12:00:48] INFO Video has filtered 14.30% of comments astro.py:91
78+
Comment data preview
79+
...
7380
```
7481
82+
By default, Astro will log output to a file named `./astro_log.txt` unless
83+
otherwise specified by the `--log-file` option or the `LOG_FILE` environment
84+
variable.
85+
7586
## Background
7687
YouTube has been a primary source of information and entertainment in my house
7788
for years. I've found that when reading comments on YouTube videos, I'm often
78-
perplexed by the content there. Wanting to understand this behavior, whether it
89+
confused by the content there. Wanting to understand this behavior, whether it
7990
was the product of real users or bots, I started researching social media usage.
8091
This project is my attempt to gather data from YouTube videos and their comments
8192
in order to analyze trends in the data, if any, in an effort to better

0 commit comments

Comments
 (0)