예제 #1
0
def main():
    # EXAMPLE VideoId = 'tCXGJQYZ9JA'
    link = input("Enter Video : ")

    #    link=H.my_form_post()
    i = 0
    while (link[i] != '='):
        i = i + 1
    id = link[i + 1:]

    # Fetch the number of comments
    # if count = -1, fetch all comments
    #    count = int(input("Enter no. of comments to extract : "))
    comments = CE.commentExtract(id, 100)
    possent = SYT.sentiment(comments)
    age = x.main()
    print('age is', age)
    print('positive content % is', possent)
    if (age > 0 and age < 5 and possent == 100):
        webbrowser.open(link)
    elif (age > 5 and age < 10 and possent > 90):
        webbrowser.open(link)
    elif (age > 10 and age < 15 and possent > 80):
        webbrowser.open(link)
    elif (age > 15 and age < 18 and possent > 75):
        webbrowser.open(link)
    elif (age > 18):
        webbrowser.open(link)
    else:
        print('not accessible')
예제 #2
0
def main():
    # EXAMPLE VideoId = 'tCXGJQYZ9JA'
    videoId = input("Enter VideoId : ")
    # Fetch the number of comments
    # if count = -1, fetch all comments
    count = int(input("Enter no. of comments to extract : "))
    comments = CE.commentExtract(videoId, count)
    SYT.sentiment(comments)
def main():
    # Sample VideoId = '6lAUk0uQWEc'
    videoId = input("Enter VideoId : ")
    # Sample Tweets Keyword = 'Death Stranding'
    twitterQuery = input("Enter Twitter Hashtag/Keyword: ")
    # Fetch the number of comments
    # if count = -1, fetch all comments
    count = int(input("Enter no. of comments/tweets to extract : "))
    comments = CE.commentExtract(videoId, count)
    SYT.sentiment(comments, twitterQuery, count)
def main():
    userpositive = open("userpositive.txt", "w")
    userpositive.write("")
    userpositive.close()
    usernegative = open("usernegative.txt", "w")
    usernegative.write("")
    usernegative.close()
    # EXAMPLE VideoId = 'tCXGJQYZ9JA'
    videoId = input("Enter VideoId : ")
    # Fetch the number of comments
    # if count = -1, fetch all comments
    count = int(input("Enter no. of comments to extract : "))
    comments = CE.commentExtract(videoId, count)
    SYT.sentiment(comments)
def main():
    videoId = sys.argv[1]
    count = 20
    comments = CE.commentExtract(videoId, count)
    SYT.sentiment(comments)
예제 #6
0
                tags.append("No Tags")  

youtube_dict = {'pubDate': pubDate,'tags': tags,'channelId': channelId,'channelTitle': channelTitle,'categoryId':categoryId,'title':title,'videoId':videoId,'viewCount':viewCount,'likeCount':likeCount,'dislikeCount':dislikeCount,'favoriteCount':favoriteCount, 'commentCount':commentCount, 'keyword':keyword, 'url':url}
df = pd.DataFrame(youtube_dict)
df.sort_values(by='viewCount',ascending=False)

import sentimentYouTube as SYT
import comment_extract as CE
import pandas as pd

df['positive']=''
df['negative']=''

for i in df['videoId']:
    print(i)
    comments = CE.commentExtract(i,100)
    pos, neg = SYT.sentiment(comments)
    df.loc[df['videoId']==i,['positive']] = pos
    df.loc[df['videoId']==i,['negative']] = neg
    
df = df[(df['positive']!='') | (df['negative']!='')]
df.loc[:,'positive'] =df['positive'].astype(int)
df.loc[:,'negative'] =df['negative'].astype(int)

df.drop_duplicates(['videoId'])
df['pubDate'] = pd.to_datetime(df.pubDate)
df['publishedDate'] = df['pubDate'].dt.strftime('%d/%m/%Y')
df1 = df[['keyword','publishedDate','title','viewCount','channelTitle','commentCount','likeCount','dislikeCount','tags','favoriteCount','videoId','channelId','categoryId','url','positive','negative']]
df1.columns = ['keyword','publishedDate','Title','viewCount','channelTitle','commentCount','likeCount','dislikeCount','tags','favoriteCount','videoId','channelId','categoryId','URL','positive','negative']

export_csv = df1.to_csv (r'/home/YoutubeAPI/Result/youtube_search_keyword_{}.csv'.format(str(HariIni)), index = None, header=True)