Example #1
0
def download_video(youtube_id, format="mp4", callback=None):
    """Downloads the video file to disk (note: this does NOT invalidate any of the cached html files in KA Lite)"""

    download_url = ("http://%s/download/videos/" %
                    (settings.CENTRAL_SERVER_HOST)) + "%s/%s"
    return videos.download_video(youtube_id, settings.CONTENT_ROOT,
                                 download_url, format, callback)
Example #2
0
    def test_downloading_in_right_location(self, download_file_method):

        download_file_method.side_effect = [
            # During the download_file for videos
            (
                None,  # doesn't matter for this test.
                Mock(type="video"),  # so download_video will succeed.
            ),
            # For downloading images
            (
                None,
                Mock(type="image"),  # so download_video will succeed.
            )
        ]

        content_dir = "/tmp"
        content_file = "something.mp3"
        expected_path = os.path.join(content_dir, content_file)

        videos.download_video("something", content_dir, format="mp3")

        url, filepath, func = download_file_method.call_args_list[0][0]
        self.assertEqual(filepath, expected_path)
Example #3
0
def download_video(youtube_id, format="mp4", callback=None):
    """Downloads the video file to disk (note: this does NOT invalidate any of the cached html files in KA Lite)"""

    download_url = ("http://%s/download/videos/" % (settings.CENTRAL_SERVER_HOST)) + "%s/%s"
    return videos.download_video(youtube_id, settings.CONTENT_ROOT, download_url, format, callback)