コード例 #1
0
def loadVideosCategories(catalog):

    videocategoriesfile = cf.data_dir + 'videos-small.csv'

    input_file = csv.DictReader(open(videocategoriesfile, encoding='utf-8'))
    for videocategory in input_file:
        model.addVideoCategory(catalog, videocategory)
コード例 #2
0
def loadVideos(catalog):
    videosfile = cf.data_dir + 'Videos/videos-large.csv'
    input_file = csv.DictReader(open(videosfile, encoding='utf-8'))
    contador = 1
    for e in input_file:
        ee = {
            'video_id':
            e['video_id'],
            'trending_date':
            datetime.strptime(e['trending_date'], '%y.%d.%m').date(),
            'title':
            e['title'],
            'channel_title':
            e['title'],
            'category_id':
            e['category_id'],
            'publish_time':
            iso.parse_date(e['publish_time']),
            'tags':
            e['tags'],
            'views':
            e['views'],
            'likes':
            e['likes'],
            'dislikes':
            e['dislikes'],
            'country':
            e['country']
        }
        model.addVideo(catalog, ee)
        model.addVideoCountry(catalog, ee, contador)
        model.addVideoCategory(catalog, ee, contador)
        contador += 1
コード例 #3
0
def loadVideos(catalog):
    """
    Args:
        catalog: Catálogo de videos.

    Carga todos los vídeos del archivo y los agrega a la lista de vídeos
    """
    videosfile = cf.data_dir + 'videos/videos-large.csv'  # videos-large para la entrega
    input_file = csv.DictReader(open(videosfile, encoding='utf-8'))

    video1 = None
    size = 0
    for video in input_file:

        filtered_video = {
            'video_id':
            video['video_id'],
            'trending_date':
            dt.datetime.strptime(video['trending_date'], '%y.%d.%m').date(),
            'title':
            video['title'],
            'channel_title':
            video['channel_title'],
            'category_id':
            int(video['category_id']),
            'publish_time':
            dt.datetime.strptime(video['publish_time'],
                                 "%Y-%m-%dT%H:%M:%S.%fZ"),
            'tags':
            video['tags'].replace("\"", ''),
            'views':
            int(video['views']),
            'likes':
            int(video['likes']),
            'dislikes':
            int(video['dislikes']),
            'country':
            video['country'],
            'dias_t':
            1
        }

        if size == 0:
            video1 = filtered_video

        size += 1
        model.addVideoCountry(catalog, filtered_video['country'],
                              filtered_video)
        model.addVideoCategory(catalog, filtered_video['category_id'],
                               filtered_video)

    return video1, size
コード例 #4
0
def loadVideoCategories(catalog):
    idsfile = cf.data_dir + 'category-id.csv'
    input_file = csv.DictReader(open(idsfile, encoding='utf-8'))
    for id in input_file:
        model.addVideoCategory(catalog, id)
コード例 #5
0
def loadVideos(catalog):

    videosfile = cf.data_dir + 'Samples/videos-large.csv'
    input_file = csv.DictReader(open(videosfile, encoding='utf-8'))
    for video in input_file:
        model.addVideoCategory(catalog, video)