コード例 #1
0
    def __load_mpp_cms_id_map(self):
        """
        加载媒资信息. vid->[vid,p_lid,cid,v_name]
        :return:
        """
        if len(self.mpp_cms_id_map) == 0:
            file_path = MediaBaseTable.get_media_conf_file_name(
                "mpp_cms_id_map")
            if file_path == "":
                sys.stderr.write("get file_path err!")
                sys.exit(-1)
            fp = open(file_path)

            # 跳过第一行
            fp.next()

            for line in fp:
                record = string.split(line.strip('\n'), "\t")
                if len(record) >= 9:
                    (vid, v_name, series_id, pid, p_name, is_full, duration,
                     cid, c_name) = record[0:9]
                    self.mpp_cms_id_map[vid] = [
                        pid, cid, series_id, is_full, duration
                    ]
                else:
                    self.drop_record += 1
                    continue

            fp.close()
コード例 #2
0
    def __load_app_cid(self):
        """
        加载媒资信息. {file_name: vid}
        :return:
        """
        if len(self.media_app_cid) == 0:
            file_path = MediaBaseTable.get_media_conf_file_name("mpp_app_cid")
            if file_path == "":
                sys.stderr.write("get file_path err!")
                sys.exit(-1)
            fp = open(file_path)

            # 跳过第一行
            fp.next()

            for line in fp:
                record = string.split(line.strip('\n'), "\t")
                if len(record) >= 3:
                    (app_cid, app_c_name, cid_plat) = record[0:3]
                    self.media_app_cid[app_cid + "|" + cid_plat] = app_c_name
                else:
                    self.drop_record += 1
                    continue

            fp.close()
コード例 #3
0
    def __load_playlist_vid_map(self):
        """
        加载媒资信息. relation_id->[playlist_id,vid]
        :return:
        """
        if len(self.playlist_vid_map) == 0:
            file_path = MediaBaseTable.get_media_conf_file_name(
                "hunantv_v_playlist_videos")
            if file_path == "":
                sys.stderr.write("get file_path err!")
                sys.exit(-1)
            fp = open(file_path)

            # 跳过第一行
            fp.next()

            for line in fp:
                record = string.split(line.strip('\n'), "\t")
                if len(record) >= 3:
                    (relation_id, playlist_id, vid) = record[0:3]
                    self.playlist_vid_map[relation_id] = [playlist_id, vid]
                else:
                    self.drop_record += 1
                    continue

            fp.close()
コード例 #4
0
    def __load_mg_media_id_map(self):
        """
        加载媒资信息. seriesId->[series_name]
        :return:
        """
        if len(self.mg_mediaId_map) == 0 or len(self.mg_mediaId_map) == 0:
            file_path = MediaBaseTable.get_media_conf_file_name(
                "asset_v_vod_media_info")
            if file_path == "":
                sys.stderr.write("get file_path err!")
                sys.exit(-1)
            fp = open(file_path)

            # 跳过第一行
            fp.next()

            for line in fp:
                record = string.split(line.strip('\n'), "\t")
                if len(record) >= 5:
                    int_id = record[0]
                    file_key = record[3]
                    file_name = record[4]
                    self.mg_mediaId_map[file_key] = [int_id, file_name]
                else:
                    self.drop_record += 1
                    continue

            fp.close()
コード例 #5
0
    def __load_bdId_name_map_name_map(self):
        """
        加载媒资信息. bdid->[bd_name]
        :return:
        """
        if len(self.bdId_name_map_name_map) == 0 or len(
                self.bdId_name_map_name_map) == 0:
            file_path = MediaBaseTable.get_media_conf_file_name(
                "asset_v_playlist")
            if file_path == "":
                sys.stderr.write("get file_path err!")
                sys.exit(-1)
            fp = open(file_path)

            # 跳过第一行
            fp.next()

            for line in fp:
                record = string.split(line.strip('\n'), "\t")
                if len(record) >= 3:
                    (bd_id, bd_name, fstlvlid) = record[0:3]
                    self.bdId_name_map_name_map[bd_id] = [bd_name, fstlvlid]
                else:
                    self.drop_record += 1
                    continue

            fp.close()
コード例 #6
0
    def __load_mobile_activity_id_map(self):
        """
        加载媒资信息. {file_name: channel}
        :return:
        """
        if len(self.mobile_activity_id_map) == 0:
            file_path = MediaBaseTable.get_media_conf_file_name(
                "mobile_activity_url")
            if file_path == "":
                sys.stderr.write("get file_path err!")
                sys.exit(-1)
            fp = open(file_path)

            # 跳过第一行
            fp.next()

            for line in fp:
                record = string.split(line.strip('\n'), "\t")
                if len(record) >= 2:
                    (activity_id, activity_url) = record[0:2]
                    self.mobile_activity_id_map[
                        activity_url.strip()] = activity_id
                else:
                    self.drop_record += 1
                    continue

            fp.close()
コード例 #7
0
    def __load_clipId_name_map(self):
        """
        加载媒资信息. clipId->[clip_name]
        :return:
        """
        if len(self.clipId_name_map) == 0 or len(self.clipId_name_map) == 0:
            file_path = MediaBaseTable.get_media_conf_file_name(
                "asset_v_clips")
            if file_path == "":
                sys.stderr.write("get file_path err!")
                sys.exit(-1)
            fp = open(file_path)

            # 跳过第一行
            fp.next()

            for line in fp:
                record = string.split(line.strip('\n'), "\t")
                if len(record) >= 2:
                    (clip_id, clip_name) = record[0:2]
                    self.clipId_name_map[clip_id] = [clip_name]
                else:
                    self.drop_record += 1
                    continue

            fp.close()
コード例 #8
0
    def __load_ott_41_cms(self, cms_map, name):
        """
        加载媒资信息. {file_name: [nns_id, nns_asset_import_id}
        加载媒资信息. {file_name: [name, sndlvl_id_list}
        :return:
        """
        if len(cms_map) == 0:
            file_path = MediaBaseTable.get_media_conf_file_name(name)
            if file_path == "":
                sys.stderr.write("get file_path err!")
                sys.exit(-1)
            fp = open(file_path)

            # 跳过第一行
            fp.next()

            for line in fp:
                record = string.split(line.strip('\n'), "\t")
                if len(record) >= 2:
                    (key, value) = record[0:2]
                    cms_map[key] = value
                else:
                    continue

            fp.close()
コード例 #9
0
    def __load_mpp_cms_cid_name_map(self):
        """
        加载媒资信息. vid->[vid,p_lid,cid,v_name]
        :return:
        """
        if len(self.cid_name_map) == 0:
            file_path = MediaBaseTable.get_media_conf_file_name("mpp_cms_id_map")
            if file_path == "":
                sys.stderr.write("get file_path err!")
                sys.exit(-1)
            fp = open(file_path)

            # 跳过第一行
            fp.next()

            for line in fp:
                record = string.split(line.strip('\n'), "\t")
                if len(record) >= 9:
                    cid = record[7]
                    c_name = record[8]
                    self.cid_name_map[cid] = c_name
                else:
                    self.drop_record += 1
                    continue

            fp.close()
コード例 #10
0
    def __load_vid_id_map(self):
        """
        加载媒资信息. vid->[v_name, is_full, duration]
        :return:
        """
        if len(self.vid_map) == 0 or len(self.vid_map) == 0:
            file_path = MediaBaseTable.get_media_conf_file_name(
                "asset_v_parts")
            if file_path == "":
                sys.stderr.write("get file_path err!")
                sys.exit(-1)
            fp = open(file_path)

            # 跳过第一行
            fp.next()

            for line in fp:
                record = string.split(line.strip('\n'), "\t")
                if len(record) >= 7:
                    (vid, v_name, duration, is_full, clipid, fstlvlid,
                     seriesid) = record[0:7]
                    self.vid_map[vid] = [
                        v_name, is_full, duration, clipid, fstlvlid, seriesid
                    ]
                else:
                    self.drop_record += 1
                    continue

            fp.close()
コード例 #11
0
    def __load_live_source_id(self):
        """
        加载媒资信息. {file_name: vid}
        :return:
        """
        if len(self.media_live_source_id) == 0:
            file_path = MediaBaseTable.get_media_conf_file_name(
                "live_source_id")
            if file_path == "":
                sys.stderr.write("get file_path err!")
                sys.exit(-1)
            fp = open(file_path)

            # 跳过第一行
            fp.next()

            for line in fp:
                record = string.split(line.strip('\n'), "\t")
                if len(record) >= 2:
                    (source_id, source_name) = record[0:2]
                    self.media_live_source_id[source_id] = source_name
                else:
                    self.drop_record += 1
                    continue

            fp.close()
コード例 #12
0
    def __load_cid_name_map(self):
        """
        加载媒资信息. cId->[name]
        :return:
        """
        if len(self.client_cid_name_map) == 0 or len(
                self.client_cid_name_map) == 0:
            file_path = MediaBaseTable.get_media_conf_file_name("cms_vclasses")
            if file_path == "":
                sys.stderr.write("get file_path err!")
                sys.exit(-1)
            fp = open(file_path)

            # 跳过第一行
            fp.next()

            for line in fp:
                record = string.split(line.strip('\n'), "\t")
                if len(record) >= 3:
                    (channel_id, vclass_name, channel_name) = record[0:3]
                    self.client_cid_name_map[channel_id] = [channel_name]
                else:
                    self.drop_record += 1
                    continue

            fp.close()
コード例 #13
0
    def loadGeoIp(self):
        """
        :summery: 加载ip_region库
        :return: 生成IP_REGION相关DICT
        """
        if len(self.GEOIP) != 0 and len(self.GEOIP_SORT) != 0:
            return

        file_path = MediaBaseTable.get_media_conf_file_name("ip_region")
        if file_path == "":
            sys.stderr.write("get file_path err!")
            sys.exit(-1)

        fp = open(file_path)

        # 跳过第一行
        fp.next()

        for i, line in enumerate(fp):
            try:
                record = string.split(line, "\t")
                rangmin = long(record[0])
                rangmax = long(record[1])
                country = record[2]
                province = record[3]
                city = record[4]
                isp = str(record[5]).strip('\n')

                self.GEOIP[rangmin] = [rangmax, country, province, city, isp]
                self.GEOIP_SORT.append(rangmin)
            except ValueError:
                sys.stderr.write(("value error,%s") % line)
        self.GEOIP_SORT.sort()
        fp.close()
コード例 #14
0
    def __load_ott_file_id_map(self):
        """
        加载媒资信息. {file_name: [vid,pid,cid,is_full,duration,series_id]}
        :return:
        """
        if len(self.ott_file_id_map) == 0:
            file_path = MediaBaseTable.get_media_conf_file_name(
                "ott_file_id_map")
            if file_path == "":
                sys.stderr.write("get file_path err!")
                sys.exit(-1)
            fp = open(file_path)

            # 跳过第一行
            fp.next()

            for line in fp:
                record = string.split(line.strip('\n'), "\t")
                if len(record) >= 7:
                    (file_name, vid, pid, cid, is_full, duration,
                     series_id) = record[0:7]
                    self.ott_41_pid_url_map[pid + file_name] = vid
                    self.ott_file_id_map[file_name] = vid
                    self.ott_vid_map[vid] = [
                        pid, cid, is_full, duration, series_id
                    ]
                else:
                    self.drop_record += 1
                    continue

            fp.close()
コード例 #15
0
    def __load_app_zt_cms_id(self):
        """
        加载媒资信息. vid->[vid,p_lid,cid,v_name]
        :return:
        """
        if len(self.media_app_zt_cms_id) == 0:
            file_path = MediaBaseTable.get_media_conf_file_name(
                "app_zt_cms_id")
            if file_path == "":
                sys.stderr.write("get file_path err!")
                sys.exit(-1)
            fp = open(file_path)

            # 跳过第一行
            fp.next()

            for line in fp:
                record = string.split(line.strip('\n'), "\t")
                if len(record) >= 3:
                    (zt_id, zt_name, zt_plat) = record[0:3]
                    self.media_app_zt_cms_id[zt_id + "|" + zt_plat] = zt_name
                else:
                    self.drop_record += 1
                    continue

            fp.close()
コード例 #16
0
    def __load_blacklist_map(self, abnormal_time):
        """
        加载媒资信息. {file_name: [vid,pid,cid,is_full,duration]}
        :return:
        """
        if len(self.did_city_map) == 0 and len(self.did_frequency_map) == 0:
            file_path = MediaBaseTable.get_media_conf_file_name(
                "abnormal_list", abnormal_time)
            if file_path == "":
                sys.stderr.write("abnormal_file_path is null")
                return
            fp = open(file_path)

            # 跳过第一行
            fp.next()

            for line in fp:
                record = string.split(line.strip('\n'), "\t")
                if len(record) >= 7:
                    (e_type, bid, did, begin_time, end_time) = record[0:5]
                    ip_str = record[6]

                    if str(e_type) in self.type_dict:
                        dict_type_map = self.type_dict[str(e_type)]

                        if str(e_type) == "4":
                            key_tmp = ip_str
                        else:
                            key_tmp = did

                        if not isinstance(dict_type_map, dict):
                            sys.stderr.write("abnormal type dict error")
                            sys.exit(-1)

                        if str(key_tmp) == "":
                            continue

                        key = "|".join([str(bid), str(key_tmp)])

                        if key not in dict_type_map:
                            dict_type_map[key] = []

                        dict_type_map[key].append([begin_time, end_time])
                    else:
                        continue
                else:
                    self.drop_record += 1
                    continue

            fp.close()
コード例 #17
0
    def __load_mpp_channel_map(self):
        """
        加载媒资信息. vid->[vid,p_lid,cid,v_name]
        :return:
        """
        if len(self.mpp_channel_map) == 0:
            file_path = MediaBaseTable.get_media_conf_file_name(
                "mpp_channel_map")
            if file_path == "":
                sys.stderr.write("get file_path err!")
                sys.exit(-1)
            fp = open(file_path)

            # 跳过第一行
            try:
                fp.next()
            except StopIteration:
                pass

            for line in fp:
                record = string.split(line.strip('\n'), "\t")
                if len(record) >= 10:
                    (ven_id, vend_source) = record[0:2]
                    device_name = record[4]
                    parent_vend_id = record[6]
                    vend_status = record[8]
                    parent_vend_type = record[9]
                    ven_key = vend_source + "|" + device_name
                    self.mpp_channel_map[ven_key] = [
                        ven_id, parent_vend_id, vend_status, parent_vend_type
                    ]
                else:
                    self.drop_record += 1
                    continue

            fp.close()