コード例 #1
0
ファイル: tests.py プロジェクト: f2k1de/deezer-downloader
 def test_youtube_dl_valid_url(self):
     url = "https://www.youtube.com/watch?v=ZbZSe6N_BXs"
     destination_file = youtubedl_download(url, "/tmp")
     file_exists = os.path.exists(destination_file)
     self.assertEqual(file_exists, True)
     file_type = magic.from_file(destination_file)
     os.remove(destination_file)
     self.assertEqual(file_type, "Audio file with ID3 version 2.4.0, contains:MPEG ADTS, layer III, v1, 64 kbps, 48 kHz, Stereo")
コード例 #2
0
 def test_youtube_dl_valid_url(self):
     os.remove("/tmp/Pharrell Williams - Happy (Video).mp3")
     url = "https://www.youtube.com/watch?v=ZbZSe6N_BXs"
     destination_file = youtubedl_download(url, "/tmp")
     file_exists = os.path.exists(destination_file)
     self.assertEqual(file_exists, True)
     file_type = magic.from_file(destination_file)
     os.remove(destination_file)
     # I test this in two seperate lines because on Ubuntu 18.04, there is an additional space in it (I don't know why. Different ffmpeg package?)
     self.assertIn("Audio file with ID3 version 2.4.0", file_type)
コード例 #3
0
 def test_youtube_dl_valid_url(self):
     url = "https://www.youtube.com/watch?v=ZbZSe6N_BXs"
     destination_file = youtubedl_download(url, "/tmp")
     file_exists = os.path.exists(destination_file)
     self.assertEqual(file_exists, True)
     file_type = magic.from_file(destination_file)
     os.remove(destination_file)
     # I test this in two seperate lines because on Ubuntu 18.04, there is an additional space in it (I don't know why. Different ffmpeg package?)
     self.assertIn(
         "Audio file with ID3 version 2.4.0, contains:MPEG ADTS, layer III",
         file_type)
     self.assertIn("64 kbps, 44.1 kHz, Stereo", file_type)
コード例 #4
0
 def test_youtube_dl_valid_url(self):
     url = "https://www.youtube.com/watch?v=ZbZSe6N_BXs"
     destination_file = youtubedl_download(url, "/tmp")
     file_exists = os.path.exists(destination_file)
     self.assertEqual(file_exists, True)
     file_type = magic.from_file(destination_file)
     os.remove(destination_file)
     # this does not work on Ubuntu 18.04: "  64 kbps" != " 64 kbps" (there is one more space!?
     self.assertIn(
         "Audio file with ID3 version 2.4.0, contains:MPEG ADTS, layer III",
         file_type)
     self.assertIn("64 kbps, 48 kHz, Stereo", file_type)
コード例 #5
0
 def test_youtube_dl_command_execution(self):
     url = "https://www.youtube.com/watch?v=ZbZSe6N_BXs&$(touch /tmp/pwned.txt)"
     youtubedl_download(url, "/tmp")
     pwn_succeeded = os.path.exists("/tmp/pwned.txt")
     self.assertEqual(pwn_succeeded, False)
コード例 #6
0
 def test_youtube_dl_invalid_url(self):
     url = "https://www.heise.de"
     with self.assertRaises(YoutubeDLFailedException):
         youtubedl_download(url, "/tmp")
コード例 #7
0
def download_youtubedl_and_queue(video_url, add_to_playlist):
    filename_absolute = youtubedl_download(
        video_url, config["download_dirs"]["youtubedl"])
    update_mpd_db(filename_absolute, add_to_playlist)
    return make_song_paths_relative_to_mpd_root([filename_absolute])