Esempio n. 1
0
def list_yt_objects(file, API_KEY):
    with open(file) as f:
        complete_videos_id = f.read().splitlines()                          # Retorna lista com a url de cada video
  
    videos_id = []
    for url in complete_videos_id:
        videos_id.append(url[32:])                                          # Retorna lista com o id da url 
 
    yt_objects = [YTstats(API_KEY,video_id,complete_video_id) 
                  for video_id, complete_video_id in zip(videos_id, complete_videos_id)] # Criando lista de objetos da classe YTstats

    return yt_objects
Esempio n. 2
0
from youtube_statistics import YTstats

API_KEY = '##########################################'
channel_id = 'UCGXsku75ELWndSG7kEihspg'

yt = YTstats(API_KEY, channel_id)
yt.extract_all()
yt.dump()
from youtube_statistics import YTstats
import os
from os.path import join, dirname
from dotenv import load_dotenv

dotenv_path = join(dirname(__file__), '.env')
load_dotenv(dotenv_path)

# Accessing variables.
ytuser = os.getenv('YTUSERID')
api_key = os.getenv('APIKEY')
# Amazing Discoveries South Africa
channel_id = "UC1oOoBASMrTyUBSltYcx0jA"

yt = YTstats(api_key, channel_id)
yt.get_channel_statistics()
Esempio n. 4
0
from youtube_statistics import YTstats

API_KEY = "AIzaSyBvp2BdZow7o9DWssirx_QgZzjFH2--pNw"
channel_id = "Randy Santel"

yt = YTstats(API_KEY, channel_id)
yt.get_channel_statistics()
Esempio n. 5
0
from youtube_statistics import YTstats
import os
from os.path import join, dirname
from dotenv import load_dotenv

dotenv_path = join(dirname(__file__), '.env')
load_dotenv(dotenv_path)

# Accessing variables.
ytuser = os.getenv('YTUSERID')
api_key = os.getenv('APIKEY')

yt = YTstats()
Esempio n. 6
0
def main():

    menu = [
        "検索キーワードでの上位閲覧チャネルの確認", "自分のチャンネルの状況を確認", "他のチャンネルの状況を確認",
        "Youtubeでデータを取り直す"
    ]

    choice = st.sidebar.radio("Menu", menu)

    if choice == "検索キーワードでの上位閲覧チャネルの確認":

        df_output = pd.read_csv("./youtube.csv")
        search_text = pd.read_csv("./search.csv")
        st.write("### ***{}***と検索した時の上位チャンネル".format(search_text.columns[1]))
        st.write("検索キーワードを選びなおす際には、「Youtubeでデータを取り直す」を選択")
        #st.write(search_text)

        df_output['viewCount'] = df_output['viewCount'].astype(int)

        values = st.slider("上位何番目を除く", min_value=0, max_value=50, step=1)

        df_output.groupby('channelTitle').sum().sort_values(
            by='viewCount', ascending=False)[values:].plot(kind='bar',
                                                           y='viewCount',
                                                           figsize=(25, 10),
                                                           fontsize=20)
        st.pyplot()

    elif choice == "自分のチャンネルの状況を確認":
        channel_status.channel_status("紗綾ちゃんねる〜saaya_channel〜.json")

    elif choice == "他のチャンネルの状況を確認":
        channel_target = ["こじはる", "ピンククラッカーズ", "森咲智美"]
        selected_channel = st.sidebar.radio("見たいチャンネルを選択", channel_target)
        if selected_channel == "こじはる":
            channel_status.channel_status("haruna_kojima's_cat_nap.json")
        elif selected_channel == "ピンククラッカーズ":
            #st.write("ピンククラッカーズ.json")
            channel_status.channel_status("ピンククラッカーズ.json")
        elif selected_channel == "森咲智美":
            st.write("こじはると同じものが出る")
            #channel_status.channel_status("森咲智美チャンネル  Tomomi Morisaki Channel.json")

    elif choice == "Youtubeでデータを取り直す":
        passcode = st.text_input("Pass codeを入力してください")
        if passcode == "1234567890":
            search_menu = ["美容", "グラビア", "日常", "ボードゲーム"]
            search_target = st.radio("上位検索したいワード", search_menu)
            if st.checkbox("{}を検索した検索データの更新".format(search_target)):
                df_search = pd.DataFrame()
                df_search[search_target] = search_target
                df_search.to_csv("./search.csv")
                df = get_video_info(part='snippet',
                                    q=search_target,
                                    order='viewCount',
                                    type='video',
                                    num=20)
                df_static = pd.DataFrame(
                    list(df['videoId'].apply(lambda x: get_statistics(x))))
                df_output = pd.concat([df, df_static], axis=1)
                df_output.to_csv("./youtube.csv")

            if st.checkbox("自分のチャンネルデータの更新"):
                channel_id = "UCYp373JfGNTCu_M9AGhg7tA"
                yt = YTstats(YOUTUBE_API_KEY, channel_id)
                yt.extract_all()
                yt.dump()  # dumps to .json
                st.write("データのダウンロードが完了しました")

            if st.checkbox("他のチャンネルデータの更新"):
                channel_id = "UCOjmYCnYlTcdoD2DKHvrV5g"
                yt = YTstats(YOUTUBE_API_KEY, channel_id)
                yt.extract_all()
                yt.dump()  # dumps to .json
                st.write("データのダウンロードが完了しました")

        else:
            st.write("やり直してください")
Esempio n. 7
0
from youtube_statistics import YTstats

API_KEY = "AIzaSyCvOo6y0w2cnaTCuprKd1lpZkIVAplN8AU"
channel_id = "UCxLzfLcNEtXsOSE_ysUTnXQ"

yt = YTstats(API_KEY, channel_id)
yt.get_channel_statistics()
yt.get_channel_video_data()
yt.dump()
Esempio n. 8
0
def get_video_data():
    yt = YTstats(YT_DATA_API_KEY, CHANNEL_ID)
    yt.get_channel_statistics()
    yt.get_channel_video_data()
    return yt.create_dict()
Esempio n. 9
0
# Reading API KEY
file = open("apikey.txt","r")
API_KEY = file.read()[:-1]
file.close()

# channel id - PowerfulJRE
channel_id = "UCzQUP1qoWDoEbmsQxvdjxgQ"

from youtube_statistics import YTstats



yt = YTstats(API_KEY,channel_id)


#data = yt.get_channel_statistics()
#yt.dump()

yt.get_channel_video_data()
Esempio n. 10
0
File: main.py Progetto: jhcf/SIUnB
from youtube_statistics import YTstats
import sys
import json

API_KEY = "Sua API Key aqui"
complete_video_id = sys.argv[1]
num_comm = sys.argv[2]

video_id = complete_video_id[32:]
#print(video_id)

yt = YTstats(API_KEY, video_id, complete_video_id, num_comm)

video_information = yt.get_video_data()
comments_information = yt.get_video_comments()

info = []
info.append(video_information)
info.append(comments_information)


def write_json(file):
    with open('youtube_info.json', 'w', encoding='utf-8') as f:
        json.dump(file, f, ensure_ascii=False, indent=4)


def write_txt(file):
    with open('youtube_info.txt', 'w') as filehandle:
        for listitem in file:
            filehandle.write('%s\n' % listitem)
Esempio n. 11
0
##

# import the path module to traverse directories
from pathlib import Path
# load the build library
from googleapiclient.discovery import build
# import the youtube stats class
from youtube_statistics import YTstats
# import youtube_statistics

# load the api key from an ignored git directory - we're not posting this to git!
dataFolder = Path("X:/Coding/YoutubeAPI/keys/")
fileToOpen = dataFolder / "gapi.txt"
with open(fileToOpen) as file:
    api_key = file.read()
# print(api_key)

# paste the interested channel id here.
# later - this will be fetched from a table in a database
# hardcoded to start
channel_id = 'UCbXgNpp0jedKWcQiULLbDTA'

yt = YTstats(api_key, channel_id)
yt.get_channel_statistics()

# the youtube api only allows for 50 items worth of videos per returned page
# we have to build further functionality to loop through all video result pages to get all the videos
yt.get_channel_video_data()

yt.dump()
Esempio n. 12
0
from youtube_statistics import YTstats

API_KEY = 'AIzaSyBD2iQAO6EFpiVdcKmt0-L5xEi6GyV75K8'
channel_id = "UCkZLRWeJemZ5GXb6PbMx70w"

#python_engineer_id = 'UCbXgNpp0jedKWcQiULLbDTA'
#channel_id = python_engineer_id

#yt = YTstats(API_KEY, channel_id)
#yt.get_channel_statistics()
#yt.get_channel_video_data()
#yt.dump()
yt = YTstats(API_KEY, channel_id)
yt.extract_all()
yt.dump()  # dumps to .json