vimeo api python using keywords to search for videos - python

I'm trying to use the Vimeo API with Python, but I'm stuck trying to find video's using keywords.
What I have is this, after successfully registering with Vimeo:
import vimeo
client = vimeo.VimeoClient(
token='my_token',
key='my_key',
secret='my_secret_key'
)
about_me = client.get('/me',params={'fields':'uri,name'})
json.loads(about_me.text)
these return my user credentials. Now I want to use a similar approach to get videos using Query keywords, like on their page. But I cannot get it to work.
So, I want to have a JSON returned with movies based on keywords (like 'interstellar trailer' and not the URI or id of Vimeo).
But for some reason, I can't get the query keyword to work, and from the linked page above, I cannot figure it out how to implement it in my code.
27-02-19: UPDATE: I figured it out, and will update my solution here, soon.

The /me endpoint only returns the user object for the authenticated user.
To get and search for videos, use the /me/videos or /videos endpoint (depending on if you are searching for videos on your own account, or searching for videos from other users public on Vimeo).

Related

How do I scrape a multiple YouTube channel's display name, creation date, and subscriber count?

I am working on a project that scrapes multiple YouTube channels display name, creation date, subscriber count, and view count. I need help creating this project because I can't seem to find anything about it. I have a YouTube API Key and I just can't seem to find anything about this.
It's a little hard to work with the sample code that the YouTube api shows. Use the curl section. Then send a request to the link that shows and use the information. for example send http request to this:
https://www.googleapis.com/youtube/v3/channels?part=statistics&id=[Channel ID]&key=[Your API]
and this address give you JSON file and you can get what you want!.
for example you can see subscribe count from channel list section in youtube api document. like this image.
you can find other things with this way!. good luck :)
also you can use this.
i'm making sample for you.
def subscribeCount(channel_id):
API = f"https://youtube.googleapis.com/youtube/v3/channels?part=statistics&id={channel_id}&key=[Enter Your Api Key]"
json_data = requests.get(API).json()
subscribeCount = json_data['items'][0]['statistics']['subscriberCount']
return subscribeCount
this sample need channel id(Like all other sections xD). and api key you Which you got from the google developer console.It then shows you the number of subscriptions to a channel. The rest of the sections work the same way.
Read the following article for more information.
How to Use the Python Requests Module With REST APIs

Is it possible to get the users who liked the instagram post using instagram graph api and python?

Below is the code which we used to extract the userinfo.
def getMediaLikes( params ) :
""" Get insights for a users account
API Endpoint:
https://graph.facebook.com/{object-id}?fields=likes.summary(true)&access_token={access-token}
Returns:
object: data from the endpoint
"""
endpointParams = dict() # parameter to send to the endpoint
endpointParams['fields'] = 'likes.summary(true)' # period
endpointParams['access_token'] = params['access_token'] # access token
url = params['graph_domain'] + object_id # endpoint url
return makeApiCall( url, endpointParams, params['debug'] ) # make the api call
But the above code is giving error:
{'error': {'message': '(#100) Tried accessing nonexisting field (reactions) on node type (ShadowIGMedia)', 'type': 'OAuthException', 'code': 100, 'fbtrace_id': 'ACiWMzqRHhPHYygSK5PO4ge'}}
Can somebody help on this? Thanks
im currently working on a project with similar problems, my approach to this problem was not to use the instagram api but instead to go to instagram.com, open my requests analyzer and understand wich requests to make to get the infos i want. Maybe you can use this approach (this way of doing things is a bit harder to use than an API but you have no limits with it).
What i would do is asking for the list of users that liked the post by copying the request my browser send when i'm doing it by hand (clicking on the list of persons that liked the post), be aware that you will need to manage the cookies instagram gives you in most cases.
I think there might be a way of doing this with the API but if there isn't... you can still do this to extract the list of peoples that liked a post.

Youtube API - how can I exclude unlisted videos?

I'm using google api client to call YouTube Data and YouTube Analytics APIs and get video stats. I'm authenticated as the owner of the channel I am querying.
I am interested in only getting the public videos uploaded in the channel. I first query the YouTube Data API to get the list of videos in the uploads playlist and once I have the list of video ids I call the youtube Analytics API for each video and get the stats I need.
The problem I'm having is that when I list all videos in the uploads playlist I get hundreds of thousands (!!!) of unlisted videos, which I don't need.
I cannot afford to download the entire list and then check status to keep only the public videos as the number is too big and I am reaching my daily quota. It would also be a very inefficient way to do it.
is there a way to list only videos with status public for a specific playlist?
This is the current method I use:
data = service.playlistItems().list(
part="snippet,status",
playlistId=playlistID,
maxResults="50",
).execute()
I couldn't find any in the youtube API documentation on how to achieve this.
Have you tried to use PlaylistItems endpoint by not being authenticated, but, instead, using only your API key parameter?
I'm assuming here -- though cannot check it myself -- that when not authenticated, the endpoint response will contain only videos that are public.
As per the doc, there are two ways an user can access any given API endpoint: using an API key or, otherwise, by way of an OAuth token.
Any user may request from Google developer's console an API key that he will pass to his endpoint of interest as the key parameter. In case of using the Python API Client Library, your code will have to be similar to this:
from googleapiclient.discovery import build
service = build(serviceName = 'youtube', version = 'v3', developerKey = DEVELOPER_KEY)
where DEVELOPER_KEY is the API key string obtained from Google. Please note that such an API key is an user's private information.
That's it: instead of OAuth, use an API key.
This doc text delineates clearly the API's concepts of authentication and authorization.
Basically, I was assuming that when using an API key instead of being authenticated via OAuth -- that is when build receives the parameter developerKey instead of credentials -- then the endpoint's response will include only public videos, even in the case when the respective API key (passed on as parameter developerKey) originates from your initial authentication account.

What permission(s) do I need to read the names of the users who posted to a Facebook page?

I want to write a Python script that reads the names of the Facebook users who wrote a message on my Facebook Page.
I'm using the facebook-sdk Python library. The lines
graph = facebook.GraphAPI(page_access_token)
profile = graph.get_object(profile_id)
posts = graph.get_connections(profile['id'], 'feed')
print(posts['data'][0]['message'])
print(posts['data'][0]['from']['name'])
work fine when I use a short-lived access token retrieved by just copying it from the Graph API explorer.
But when I generate a never-expiring page access token (read here), there is an error in the last line where the Python script wants to retrieve the name. (KeyError: 'from')
So how do i set the right permissions? The access token has user_about_me, user_posts, read_page_mailboxes, manage_pages, publish_pages, public_profile permissions, but it still doesn't work. Maybe I did something wrong setting up the app I created to retrieve a new access token?
Or maybe this isn't a permissions issue after all? (See my previous question.)
You need to specify the fields you want to retrieve manually if you're using v2.4 or higher. Unfortunately this is not documented in the project you're using:
posts = graph.get_connections(profile['id'], 'feed', 'fields=id,message,from')
should work I guess according to https://github.com/pythonforfacebook/facebook-sdk/blob/master/facebook/init.py#L117

Get latest Instagram user photos using python-instagram library

I am using python-instagram api in my application in order to fetch recent photos from my instagram account. I am using following approach but couldn't succeed:
from instagram.client import InstagramAPI
api = InstagramAPI(client_id='MY_CLIENT_ID', client_secret='MY_CLIENT_SECRET')
recent_media= api.user_recent_media(my_user_id, 6, max_id)
for media in recent_media:
print media.images['standard_resolution'].url
endfor
Here I don't understand what max_id parameter is. I have tried ignoring max_id, but it doesn't work. I have tried to get popula media, and it worked:
popular_media = api.media_popular(count=6)
Can anyone give me some idea? I am a PHP programmer and kinda new in python. All I need is - to get my recent instagram photos (6 of them) and show them in web page with an url so that user can click them. Do I need use access token for this? I hope not. Because I don't have any experience with python API yet.
Try to authenticate your api first, this can be the case. You do not necessarily have access to user recent media otherwise
Use named arguments in this case to be sure.
api.user_recent_media(user_id=user_id, count=10)
Max_id is optional and specifies, that you want to see photos with smaller id's.
(e.g res=5,4,3,2,1 with max_id = 3 res=3,2,1)

Categories

Resources