Example #1
0
def add_video(path, manual_feed=None):
    """Add a new video

    :returns: True if we create a new Item object.
    """
    path = os.path.abspath(path)
    if item.Item.have_item_for_path(path):
        logging.debug("Not adding duplicate video: %s",
                      path.decode('ascii', 'ignore'))
        # get the first item and undelete it
        item_for_path = _get_item_for_path(path)
        if item_for_path is not None:
            if item_for_path.deleted:
                item_for_path.make_undeleted()
            if _command_line_videos is not None:
                _command_line_videos.add(item_for_path)
            return False
    if manual_feed is None:
        manual_feed = feed.Feed.get_manual_feed()
    file_item = item.FileItem(path,
                              feed_id=manual_feed.get_id(),
                              mark_seen=True)
    if _command_line_videos is not None and file_item.id_exists():
        _command_line_videos.add(file_item)
    return True
Example #2
0
 def test_phantom_feed_checking(self):
     f = feed.Feed(u"http://feed.uk")
     i = item.Item(item.FeedParserValues({}), feed_id=f.id)
     i2 = item.FileItem(self.make_temp_path('.txt'), feed_id=f.id)
     self.check_object_list_fails_test([i])
     self.check_fix_if_possible([i, i2], [])
     self.check_object_list_passes_test([i, f])
     self.check_object_list_passes_test([])