def add_update_record(self, channel_id, start_stamp, start_time, record_num):
         ch_info = channel_info(channel_id=channel_id,program_id=0,
                                video_id=0,title='',
                                start_time=start_time,start_stamp=start_stamp,
                                date=0,vender_id=0,
                                time_length=0,record_num=record_num)
         self.session.add(ch_info)       
Example #2
0
    def processUpdate(self):
        data_type = self.data_desc.getDataType()
        if DATATYPE.data_type_update_program == data_type:
            channel_id = self.data_desc.getModifier("channel_id")
            record_num = self.data_desc.getModifier("record_num")
            details = self.data_desc.getModifier("details")
            self.delete_now_record_videos(channel_id, record_num)
            for video in details:
                date = video['start_time'][0:10]
                dt = time.strptime(date, "%Y-%m-%d")
                day = (int(time.mktime(dt)) - time.timezone) / (60 * 60 * 24)
                time_array = time.strptime(video["start_time"],
                                           "%Y-%m-%d %H:%M:%S")
                time_stamp = int(time.mktime(time_array)) - 8 * 60 * 60
                time_length = video["time_length"]
                ch_info = channel_info(channel_id=channel_id,
                                       program_id=video["program_id"],
                                       video_id=video["video_id"],
                                       title=video["title"],
                                       start_time=video["start_time"],
                                       start_stamp=time_stamp,
                                       date=day,
                                       vender_id=video["vender_id"],
                                       time_length=video["time_length"],
                                       record_num=record_num)
                self.session.add(ch_info)
            self.update_record_start_time(record_num, channel_id, details)
            gt_videos = self.get_greater_videos(channel_id, record_num)
            if len(gt_videos) > 0:
                diff_time = gt_videos[0].start_stamp - (time_stamp +
                                                        time_length)
                self.update_greater_videos(gt_videos, diff_time)

            self.session.commit()
            self.flush_channel_detailpage(channel_id)
            for video in details:
                self.flush_channel_video(video["program_id"], channel_id)

        elif DATATYPE.data_type_update_record == data_type:
            channel_id = self.data_desc.getModifier("channel_id")
            record_num = self.data_desc.getModifier("record_num")
            start_stamp = 0
            start_time = '0000-00-00 00:00:00'
            time_list = self.get_limit_one_record(channel_id, record_num)
            if len(time_list) > 0 and time_list[0].start_stamp != 0:
                start_stamp = time_list[
                    0].start_stamp + 8 * 60 * 60 + time_list[0].time_length
                timeArray = time.localtime(start_stamp)
                start_time = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
            self.add_update_record(channel_id, start_stamp, start_time,
                                   record_num)

            self.session.commit()
Example #3
0
 def add_update_record(self, channel_id, start_stamp, start_time,
                       record_num):
     ch_info = channel_info(channel_id=channel_id,
                            program_id=0,
                            video_id=0,
                            title='',
                            start_time=start_time,
                            start_stamp=start_stamp,
                            date=0,
                            vender_id=0,
                            time_length=0,
                            record_num=record_num)
     self.session.add(ch_info)
 def add_channel_info(self, details, channel_id, record_num):
     for video in details:
         date = video['start_time'][0: 10]
         dt = time.strptime(date, "%Y-%m-%d")
         day = (int(time.mktime(dt)) - time.timezone)/(60*60*24)
         time_array = time.strptime(video["start_time"], "%Y-%m-%d %H:%M:%S")
         time_stamp = int(time.mktime(time_array)) - 8 * 60 * 60
         time_length = video["time_length"]
         ch_info = channel_info(channel_id=channel_id,program_id=video["program_id"],
                                     video_id=video["video_id"],title=video["title"],
                                     start_time=video["start_time"],start_stamp=time_stamp,
                                     date=day,vender_id=video["vender_id"],
                                     time_length=video["time_length"],record_num=record_num)
         self.session.add(ch_info)
    def processUpdate(self):
        data_type = self.data_desc.getDataType()
        if DATATYPE.data_type_update_program == data_type:
            channel_id = self.data_desc.getModifier("channel_id")
            record_num = self.data_desc.getModifier("record_num")
            details = self.data_desc.getModifier("details")
            self.delete_now_record_videos(channel_id, record_num)
            for video in details:
                date = video['start_time'][0: 10]
                dt = time.strptime(date, "%Y-%m-%d")
                day = (int(time.mktime(dt)) - time.timezone)/(60*60*24)
                time_array = time.strptime(video["start_time"], "%Y-%m-%d %H:%M:%S")
                time_stamp = int(time.mktime(time_array)) - 8 * 60 * 60
                time_length = video["time_length"]
                ch_info = channel_info(channel_id=channel_id,program_id=video["program_id"],
                                            video_id=video["video_id"],title=video["title"],
                                            start_time=video["start_time"],start_stamp=time_stamp,
                                            date=day,vender_id=video["vender_id"],
                                            time_length=video["time_length"],record_num=record_num)
                self.session.add(ch_info)
            self.update_record_start_time(record_num, channel_id, details)
            gt_videos = self.get_greater_videos(channel_id, record_num) 
            if len(gt_videos) > 0:
                diff_time = gt_videos[0].start_stamp - (time_stamp + time_length)
                self.update_greater_videos(gt_videos, diff_time)

            self.session.commit()
            self.flush_channel_detailpage(channel_id)
            for video in details:
                self.flush_channel_video(video["program_id"], channel_id)

        elif DATATYPE.data_type_update_record == data_type:
            channel_id = self.data_desc.getModifier("channel_id")
            record_num = self.data_desc.getModifier("record_num")
            start_stamp = 0
            start_time = '0000-00-00 00:00:00'
            time_list = self.get_limit_one_record(channel_id, record_num)
            if len(time_list) > 0 and time_list[0].start_stamp != 0:
                start_stamp = time_list[0].start_stamp + 8 * 60 * 60 + time_list[0].time_length
                timeArray = time.localtime(start_stamp)
                start_time = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
            self.add_update_record(channel_id, start_stamp, start_time, record_num)
            
            self.session.commit()
Example #6
0
 def add_channel_info(self, details, channel_id, record_num):
     for video in details:
         date = video['start_time'][0:10]
         dt = time.strptime(date, "%Y-%m-%d")
         day = (int(time.mktime(dt)) - time.timezone) / (60 * 60 * 24)
         time_array = time.strptime(video["start_time"],
                                    "%Y-%m-%d %H:%M:%S")
         time_stamp = int(time.mktime(time_array)) - 8 * 60 * 60
         time_length = video["time_length"]
         ch_info = channel_info(channel_id=channel_id,
                                program_id=video["program_id"],
                                video_id=video["video_id"],
                                title=video["title"],
                                start_time=video["start_time"],
                                start_stamp=time_stamp,
                                date=day,
                                vender_id=video["vender_id"],
                                time_length=video["time_length"],
                                record_num=record_num)
         self.session.add(ch_info)