示例#1
0
 def __init__(self, legacy_filepath=None):
     super().__init__()
     config = utilities.ConfigHandler()
     self.legacy_filepath = config.records_filepath + ".legacy" if legacy_filepath is None \
         else legacy_filepath
     self.legacy_data = json.load(open(self.legacy_filepath, mode='r'))
     self.videos_added = self.import_legacy()
示例#2
0
 def __init__(self):
     self.config = utilities.ConfigHandler()
     ranks_dictionary = json.load(open(self.config.ranks_filepath,
                                       mode='r'))
     self.max_length = self.config
     self.ranks = ranks_dictionary['ranks']
     self.filtered_channels = ranks_dictionary['filters']['channels']
     self.filtered_video_titles = ranks_dictionary['filters']['videos']
示例#3
0
    def get_channel_data(self):
        self.channel_data = []
        config = utilities.ConfigHandler()
        subscriptions = json.load(open(config.subscriptions_filepath,
                                       mode='r'))['details']

        for channel_name in self.channels:
            if channel_name in subscriptions:
                self.channel_data.append(subscriptions[channel_name])
示例#4
0
 def __init__(self, **kwargs):
     self.newest = []
     self.name = kwargs['name']
     self.playlist_id = kwargs['uploads']
     self.channel_id = kwargs['id']
     self.records = Records()
     config = utilities.ConfigHandler()
     self.queue_id = config.variables['QUEUE_ID']
     self.date_format = config.variables['YOUTUBE_DATE_FORMAT']
     self.oldest_date = kwargs['oldest_date']
示例#5
0
 def __init__(self):
     config = utilities.ConfigHandler()
     self.date = datetime.now().strftime(config.variables['DATE_FORMAT'])
     self.youtube_date_format = config.variables['YOUTUBE_DATE_FORMAT']
     self.filepath = config.records_filepath
     self.data = json.load(open(self.filepath, mode='r'))
     if 'dates' not in self.data:
         self.data['dates'] = {'previously_added': {}}
     if 'latest' not in self.data:
         self.data['latest'] = {}
     self.videos_added = self.data['dates']
     self.latest_videos = self.data['latest']
示例#6
0
 def __init__(self):
     config = utilities.ConfigHandler()
     self.id = config.variables['QUEUE_ID']
     self.ranks = ranks.RanksHandler()
     self.subscriptions = json.load(
         open(config.subscriptions_filepath, mode='r'))
     self.channel_details = self.subscriptions['details']
     self.records = Records()
     days_to_search = config.variables['DAYS_TO_SEARCH']
     self.date_format = config.variables['YOUTUBE_DATE_FORMAT']
     self.oldest_date = datetime.now() - timedelta(days=days_to_search)
     logger.write(
         self.oldest_date.strftime(config.variables['EVENT_LOG_FORMAT']))
示例#7
0
    def write(self):
        config = utilities.ConfigHandler()
        filepath = config.ranks_filepath
        date_format = config.variables['LOG_DATE_FORMAT']
        log_date = datetime.now()
        backup_suffix = log_date.strftime(date_format)

        # Backup subscription file
        backup_ranks_file = "{0}.{1}".format(filepath, backup_suffix)
        os.rename(src=filepath, dst=backup_ranks_file)

        # Write new subscription file
        fp = open(filepath, mode='w')
        utilities.print_json(self.data, fp=fp)
示例#8
0
 def __init__(self):
     config = utilities.ConfigHandler()
     self.data = json.load(open(config.ranks_filepath, mode='r'))
     self.ranks = self.data['ranks']
     self.filtered = self.data['filters']
     self.filtered_channels = []
     for channel_name in self.filtered['channels']:
         self.filtered_channels.append(
             self.filtered['channels'][channel_name])
     self.playlists = self.data['playlist_ids']
     self.queues = self.data['queues']
     for tier in config.variables['TIER_PLAYLISTS']:
         self.playlists[tier] = config.variables['TIER_PLAYLISTS'][tier]
     self.rank_data = []