Skip to content

Commit

Permalink
Added initial support for video thumbnail fetches
Browse files Browse the repository at this point in the history
Summary: Added support for Python SDK video thumbnail tests.

Test Plan:
1. upload video assigned to ad account, if not already there.
2. facepy
3. vid = AdVideo(fbid=<VIDEO_ID>)
4. vid.get_thumbnails()

Output of above:
https://phabricator.fb.com/P20051337

Unit tests:
python -m facebookads.test.unit
............................
----------------------------------------------------------------------
Ran 28 tests in 0.015s

OK

Integration tests:
ython -m facebookads.test.integration
....................
----------------------------------------------------------------------
Ran 20 tests in 27.928s

OK
  • Loading branch information
alexlupu authored and Ritu committed Oct 8, 2015
1 parent 39c34a7 commit 6e0b4e4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
1 change: 1 addition & 0 deletions facebookads/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ def remove_labels(self, labels=None):
params={'adlabels': [{'id': label} for label in labels]},
)


class ValidatesFields(object):
def __setitem__(self, key, value):
if key not in self.Field.__dict__:
Expand Down
34 changes: 27 additions & 7 deletions facebookads/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -1448,33 +1448,31 @@ def get_endpoint(cls):
return 'adgroups'

def get_ad_creatives(self, fields=None, params=None):
"""Returns iterator over AdCreative's associated with this ad."""
"""Returns iterator over AdCreatives associated with this ad."""
return self.iterate_edge(AdCreative, fields, params)

def get_targeting_description(self, fields=None, params=None):
"""
Returns TargetingDescription object associated with this ad.
"""
"""Returns TargetingDescription object associated with this ad."""
return self.edge_object(TargetingDescription, fields, params)

def get_keyword_stats(self, fields=None, params=None):
"""Returns iterator over KeywordStats's associated with this ad."""
"""Returns iterator over KeywordStats associated with this ad."""
return self.edge_object(KeywordStats, fields, params)

def get_ad_preview(self, fields=None, params=None):
"""Returns AdGroupPreview object associated with this ad."""
return self.edge_object(AdGroupPreview, fields, params)

def get_reach_estimate(self, fields=None, params=None):
"""Returns iterator over ReachEstimate's associated with this ad."""
"""Returns iterator over ReachEstimates associated with this ad."""
return self.iterate_edge(ReachEstimate, fields, params)

def get_stats(self, fields=None, params=None):
"""Returns AdStats object associated with this ad."""
return self.edge_object(AdStats, fields, params)

def get_click_tracking_tag(self, fields=None, params=None):
"""Returns iterator over ClickTrackingTag's associated with this ad."""
"""Returns iterator over ClickTrackingTags associated with this ad."""
return self.iterate_edge(ClickTrackingTag, fields, params)

def get_conversion_stats(self, fields=None, params=None):
Expand Down Expand Up @@ -1818,6 +1816,28 @@ def waitUntilEncodingReady(self, interval=30, timeout=600):
timeout,
)

def get_thumbnails(self, fields=None, params=None):
"""
Returns all the thumbnails associated with the ad video
"""
return self.iterate_edge(VideoThumbnail, fields, params)


class VideoThumbnail(AbstractObject):

class Field(object):
id = 'id'
height = 'height'
name = 'name'
scale = 'scale'
uri = 'uri'
width = 'width'
is_preferred = 'is_preferred'

@classmethod
def get_endpoint(cls):
return 'thumbnails'


class AdPreview(AbstractObject):

Expand Down

0 comments on commit 6e0b4e4

Please sign in to comment.