DCASE-REPO / dcase_util

A collection of utilities for Detection and Classification of Acoustic Scenes and Events
https://dcase-repo.github.io/dcase_util/
MIT License
127 stars 33 forks source link

load youtube videos #7

Closed mic2zar closed 6 years ago

mic2zar commented 6 years ago

Description

There is an example how to load youtube videos in dcase_util tutorials. Actually this code does not work, when executed on Windows machine.

Steps/Code to Reproduce

Just execute:

audo_container = dcase_util.containers.AudioContainer().load_from_youtube(
    query_id='2ceUOv8A3FE',
    start=1,
    stop=5,
    silent=False
)

Actual Results

Download youtube item    : 0.00B [00:00, ?B/s]
Download youtube item    :   1%|7                                                   | 16.0/1.11k [00:00<00:17, 61.8B/s]
Download youtube item    :  14%|#######6                                             | 160/1.11k [00:00<00:10, 86.7B/s]
Download youtube item    :  95%|#################################################4  | 1.06k/1.11k [00:00<00:00, 123B/s]
Download youtube item    : 3.36kB [00:00, 176B/s]                                                                      
Download youtube item    : 7.44kB [00:00, 251B/s]
Download youtube item    : 13.1kB [00:00, 357B/s]
Download youtube item    : 19.6kB [00:03, 484B/s]
Download youtube item    : 25.5kB [00:03, 689B/s]
Download youtube item    : 29.3kB [00:05, 818B/s]
Download youtube item    : 34.3kB [00:07, 1.04kB/s]
---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
C:\ProgramData\Anaconda3\lib\site-packages\dcase_util\containers\audio.py in load_from_youtube(self, query_id, start, stop, mono, silent)
   1052                 quiet=True,
-> 1053                 callback=callback
   1054             )

C:\ProgramData\Anaconda3\lib\site-packages\pafy\backend_shared.py in download(self, filepath, quiet, progress, callback, meta, remux_audio)
    663             else:
--> 664                 os.replace(temp_filepath, filepath)
    665 

PermissionError: [WinError 5] Access is denied: 'C:\\Users\\mzaremba\\AppData\\Local\\Temp\\tmpwmvukw04.webm.temp' -> 'C:\\Users\\mzaremba\\AppData\\Local\\Temp\\tmpwmvukw04.webm'

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
<ipython-input-33-39ba8ece2da0> in <module>()
      3     start=1,
      4     stop=5,
----> 5     silent=False
      6 )

C:\ProgramData\Anaconda3\lib\site-packages\dcase_util\containers\audio.py in load_from_youtube(self, query_id, start, stop, mono, silent)
   1094         except (IOError, BadStatusLine, ExtractorError) as e:
   1095             # Store files with errors
-> 1096             raise IOError(e.message)
   1097 
   1098         except (KeyboardInterrupt, SystemExit):

AttributeError: 'PermissionError' object has no attribute 'message'

Versions

Windows-10-10.0.14393-SP0 Python 3.6.5 |Anaconda custom (64-bit)| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] NumPy 1.14.1 SciPy 1.0.1 Matplotlib 2.2.2 librosa 0.6.0

dangpzanco commented 6 years ago

Check out the pull request I did last week for a fix.

#6 Fix a bug in AudioContainer's load_from_youtube method

toni-heittola commented 6 years ago

Pull request by dangpzanco has been merged now to the develop branch, and will be included in the upcoming release. Please, report if this did not solve your issue.

mic2zar commented 6 years ago

I confirm it resolves the issue on Windows machine.