def channelBasicData(channel_id): """ extract the basic data about the cannel nedded just to identify the out put is the following: a dictionary of this form :: {'createdAt': '2011-09-20T13:33:46.000Z', 'channelTitle': 'Anes Tina', 'country': 'DZ', 'channelId': 'UCHCsGx9byqxSw6f1JQVBk6Q', 'pic' : 'the url, with a size of 240x240'} """ # load the data from the storage location, look for DATA_PATH in config.py data = md.loadData(CHANNEL_PATH + channel_id + '.json') dic = {} # get the channel id and title dic['channelId'] = data['items'][0]['id'] dic['channelTitle'] = data['items'][0]['snippet']['title'] dic['createdAt'] = data['items'][0]['snippet']['publishedAt'] dic['pic'] = data['items'][0]['snippet']['thumbnails']['medium']['url'] # the country is not always provided try: dic['country'] = data['items'][0]['snippet']['country'] except Exception as e: dic['country'] = '' return dic
def videoAllData(video_id): """ this one is a combinations of both channelBasicData() and channelStatsData() it returns all the data about he channel. with this following format: {'statistics': {'dislikeCount': '5837', 'likeCount': '43726', 'viewCount': '1997007'}, 'basic': {'videoId': 'hkX1Q4nZJHw', 'videoTitle': 'Les femmes EN Algérie . Anes Tina . المرأة في الجزائر', 'createdAt': '2016-03-07T17:55:50.000Z'}} """ # load the data from the storage location, look for DATA_PATH in config.py data = md.loadData(VIDEO_PATH + video_id + '.json') dic = {} dic['basic'] = {} # get the video id and title dic['basic']['videoId'] = data['items'][0]['id'] dic['basic']['videoTitle'] = data['items'][0]['snippet']['title'] dic['basic']['createdAt'] = data['items'][0]['snippet']['publishedAt'] dic['basic']['channelId'] = data['items'][0]['snippet']['channelId'] dic['basic']['channelTitle'] = data['items'][0]['snippet']['channelTitle'] dic['statistics'] = data['items'][0]['statistics'] return dic
def videoStatsData(video_id): """ extract the necessary data about the video nedded in our statistics the out put is the following: a dictionary of this form :: {'dislikeCount': '190', 'likeCount': '2096091', 'viewCount': '204096646'} """ # load the data from the storage location, look for DATA_PATH in config.py data = md.loadData(VIDEO_PATH + video_id + '.json') return data['items'][0]['statistics']
def channelStatsData(channel_id): """ extract the necessary data about the cannel nedded in our statistics the out put is the following: a dictionary of this form :: {'videoCount': '190', 'subscriberCount': '2096091', 'viewCount': '204096646'} """ # load the data from the storage location, look for DATA_PATH in config.py data = md.loadData(CHANNEL_PATH + channel_id + '.json') # get statistics data and delete the ungonna used ones dic = data['items'][0]['statistics'] dic.pop('commentCount') dic.pop('hiddenSubscriberCount') return dic
def channelAllData(channel_id): """ this one is a combinations of both channelBasicData() and channelStatsData() it returns all the data about he channel. with this following format: {'statistics': {'viewCount': '204096646', 'subscriberCount': '2096091', 'videoCount': '190'}, 'basic': {'pic': 'https://yt3.ggpht.com/a-/AAuE7mBMNlex 3hbyn_a7qGuYDLvT7jsq2Mkh-6Ul6Q=s240-mo-c-c0xffffffff-rj-k-no', 'channelId': 'UCHCsGx9byqxSw6f1JQVBk6Q', 'channelTitle': 'Anes Tina', 'country': 'DZ', 'createdAt': '2011-09-20T13:33:46.000Z'}} """ # load the data from the storage location, look for DATA_PATH in config.py data = md.loadData(CHANNEL_PATH + channel_id + '.json') dic = {} dic['basic'] = {} # get statistics data and delete the ungonna used ones dic['statistics'] = data['items'][0]['statistics'] dic['statistics'].pop('commentCount') dic['statistics'].pop('hiddenSubscriberCount') # get the channel id and title dic['basic']['channelId'] = data['items'][0]['id'] dic['basic']['channelTitle'] = data['items'][0]['snippet']['title'] dic['basic']['createdAt'] = data['items'][0]['snippet']['publishedAt'] dic['basic']['pic'] = data['items'][0]['snippet']['thumbnails']['medium'][ 'url'] # the country is not always provided try: dic['basic']['country'] = data['items'][0]['snippet']['country'] except Exception as e: dic['basic']['country'] = '' return dic
def videoBasicData(video_id): """ extract the basic data about the video needed just to identify the out put is the following: a dictionary of this form :: {'videoTitle': 'Les femmes EN Algérie . Anes Tina . المرأة في الجزائر', 'videoId': 'hkX1Q4nZJHw', 'createdAt': '2016-03-07T17:55:50.000Z'} """ # load the data from the storage location, look for DATA_PATH in config.py data = md.loadData(VIDEO_PATH + video_id + '.json') dic = {} # get the video id and title dic['videoId'] = data['items'][0]['id'] dic['videoTitle'] = data['items'][0]['snippet']['title'] dic['createdAt'] = data['items'][0]['snippet']['publishedAt'] dic['channelId'] = data['items'][0]['snippet']['channelId'] dic['channelTitle'] = data['items'][0]['snippet']['channelTitle'] return dic