Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

match_filter fails when using in embedded Python code #4925

Closed
GijsTimmers opened this issue Feb 10, 2015 · 2 comments
Closed

match_filter fails when using in embedded Python code #4925

GijsTimmers opened this issue Feb 10, 2015 · 2 comments

Comments

@GijsTimmers
Copy link

@GijsTimmers GijsTimmers commented Feb 10, 2015

I want to only download YouTube videos with a valid upload date. If the upload date is not available, I don't want to download the video. Therefore, match_filter could be interesting.

In [8]: import youtube_dl

In [9]: ydl = youtube_dl.YoutubeDL({"match_filter": "upload_date"})

In [10]: ydl.download(["https://www.youtube.com/watch?v=cU2dZz18P0c"])
[youtube] cU2dZz18P0c: Downloading webpage
[youtube] cU2dZz18P0c: Extracting video information
[youtube] cU2dZz18P0c: Downloading DASH manifest
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-fc60485bb9c2> in <module>()
----> 1 ydl.download(["https://www.youtube.com/watch?v=cU2dZz18P0c"])

/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.pyc in download(self, url_list)
   1385             try:
   1386                 # It also downloads the videos
-> 1387                 res = self.extract_info(url)
   1388             except UnavailableVideoError:
   1389                 self.report_error('unable to download video')

/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.pyc in extract_info(self, url, download, ie_key, extra_info, process)
    642                 self.add_default_extra_info(ie_result, ie, url)
    643                 if process:
--> 644                     return self.process_ie_result(ie_result, download, extra_info)
    645                 else:
    646                     return ie_result

/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.pyc in process_ie_result(self, ie_result, download, extra_info)
    688         if result_type == 'video':
    689             self.add_extra_info(ie_result, extra_info)
--> 690             return self.process_video_result(ie_result, download=download)
    691         elif result_type == 'url':
    692             # We have to add extra_info to the results because it may be

/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.pyc in process_video_result(self, info_dict, download)
   1143                 new_info = dict(info_dict)
   1144                 new_info.update(format)
-> 1145                 self.process_info(new_info)
   1146         # We update the info dict with the best quality format (backwards compatibility)
   1147         info_dict.update(formats_to_download[-1])

/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.pyc in process_info(self, info_dict)
   1168             info_dict['format'] = info_dict['ext']
   1169 
-> 1170         reason = self._match_entry(info_dict, incomplete=False)
   1171         if reason is not None:
   1172             self.to_screen('[download] ' + reason)

/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.pyc in _match_entry(self, info_dict, incomplete)
    597             match_filter = self.params.get('match_filter')
    598             if match_filter is not None:
--> 599                 ret = match_filter(info_dict)
    600                 if ret is not None:
    601                     return ret

TypeError: 'str' object is not callable
@phihag
Copy link
Contributor

@phihag phihag commented Feb 10, 2015

As documented, in the API match_filter is a callable (i.e. function), not a string. You have two options:

  1. Configure {"match_filter": youtube_dl.utils.match_filter_func("upload_date")}
  2. Cut out the middle-man and implement your own filtering function
@phihag phihag closed this Feb 10, 2015
@GijsTimmers
Copy link
Author

@GijsTimmers GijsTimmers commented Feb 11, 2015

OK, thank you for clarifying this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.