Skip to content

Commit e054212

Browse files
committed
Validating YouTubeSearch
1 parent f1b5ea6 commit e054212

File tree

6 files changed

+26
-11
lines changed

6 files changed

+26
-11
lines changed

.DS_Store

0 Bytes
Binary file not shown.

constants/entities

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
clapton
22
claptons
3-
bieber
3+
bieber
4+
music video

examples/ytpy.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
import couchdb
22

3-
import utils as tech
3+
from sys import argv,path
4+
5+
46

5-
from sys import argv
7+
8+
#initialization
9+
path.append('/Volumes/My Book/Dropbox/ToxTweet/Software/APIs/ytpy/lib')
10+
path.append('/Volumes/My Book/Dropbox/ToxTweet/Software/APIs/ytpy/examples')
11+
12+
import utils as tech
613

714
from switch import *
815
from YouTubeSearch import *
916

17+
1018
def list_comments(video):
1119
return tech.lemmingtize(tech.remove_stopwords(video['comments']))
1220

@@ -45,11 +53,15 @@ def save(video,format='txt'):
4553
print 'You are searching YouTube for %s' % drug
4654

4755
data = YouTubeSearch(drug)
48-
'''
56+
57+
def update_database
58+
4959
server = couchdb.Server()
50-
#edit this back later: dbname = 'yt-%s' % drug
51-
dbname = 'yt-k2/spice'
52-
for video in cocaine_comments:
53-
# save(video)
60+
61+
dbname = 'yt-%s' % drug
62+
for video in data:
63+
print video['comments']
64+
'''
65+
save(video)
5466
server[dbname].save(video)
5567
'''

lib/YouTubeSearch.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from numpy.random import random
99
from termcolor import colored,cprint
1010

11+
1112
class YouTubeSearch(object):
1213
def __init__(self,term,exclude_videos=True):
1314
self.term = term
@@ -21,9 +22,10 @@ def __init__(self,term,exclude_videos=True):
2122
self.video_params = {
2223
'alt':'json',
2324
'max-results':50}
24-
25-
self.video_stopwords = ''.join(open('.videostops','rb').readlines()) if exclude_videos else None
26-
25+
26+
self.exopath = '/Volumes/My Book/Dropbox/ToxTweet/Software/APIs/ytpy/constants'
27+
self.video_stopwords = ''.join(open(self.exopath+'/'+'entities','rb').readlines()) if exclude_videos else None
28+
2729
def __repr__(self):
2830
return self.__class__.__name__+repr((self.term))
2931

lib/YouTubeSearch.pyc

161 Bytes
Binary file not shown.

lib/utils.pyc

-4.51 KB
Binary file not shown.

0 commit comments

Comments
 (0)