I am only getting upload activities from YouTube API, rather than getting other activities e.g. like, recommendation, subscription, favourite - youtube-api

I am using the YouTube API to get the activities of the authenticated user e.g. like, subscription, etc. The API should only return my the items with snippet.type=upload
This is my request call in python:
request = youtube.activities().list(
part="snippet,contentDetails",
# channelId=channelId,
mine=True,
maxResults=25
)
Here is the link to the API: https://developers.google.com/youtube/v3/docs/activities/list

Like you mentioned, (once again) YouTube Data API v3 doesn't work as expected by the documentation.
I think the best way to go is parsing webpages (when logged) like these ones:
Likes: https://myactivity.google.com/page?page=youtube_likes
Subscriptions: https://myactivity.google.com/page?page=youtube_subscriptions
This webpage describes a few webpages like above: https://myactivity.google.com/more-activity
If you go this way, don't hesitate to share your parsing code with others for instance on this repository.

Related

Is there a way to access the comments I make on YouTube through the API?

I'm trying to retrieve the comments I've made on YouTube to turn them into Markdown files, but I can't find a way to do it filtering by user in the API documentation.
I thought it would be possible since the Google account has a link for it but when using the parameter "channelID" in the API to list comments as it says in the documentation, it gives back a 400 error.
You are looking for the comments your channel posted, however when using CommentThreads: list with channelId=YOUR_CHANNEL_ID you are listing comments people wrote on your channel, as described the documentation:
channelId
string
The channelId parameter instructs the API to return comment threads containing comments about the specified channel. (The response will not include comments left on videos that the channel uploaded.)
One more time YouTube Data API v3 AFAIK doesn't provide this basic feature.
You have two possibilities:
Use Google TakeOut (make sure to export Comments in YouTube and YouTube Music)
Web-scrap the webpage you provided

Is there any methods to get the like list of a tweet?

I want to get the complete like list of a specific tweet, but the Twitter API only provided an API that can retrieve the 100 most recent users who liked the specific tweet. I also looked for Twitter crawlers on Github, but they all worked in a user-oriented manner, ie they can only get a list of liked tweets of a user, not a list of liking users of a specific tweet.
I also tried to crawl the list using selenium, but maybe due to my limited skill, it didn't work well. I don't want to spend a lot of time studying selenium and front-end knowledge just to accomplish a simple thing, so are there any open source codes or twitter APIs that can do this?
Yes. This has just been announced in the Twitter API v2.
Previously, you were limited to the 100 most recent Likes or Retweets with these endpoints. We heard your feedback that this was too limiting and have updated these endpoints to now return all results. To retrieve a complete list of Likes and Retweets, you can now use pagination.
Use the v2 Likes lookup endpoint: GET /2/tweets/:id/liking_users

Feed for YouTube Subscription Collection

I am using YouTube's new "Subscription Collection" feature: it works great and is exactly what I'm looking for: the complete list of videos for a subset of my subscriptions.
Now I would like to get this list of videos through the API.
To be clear: I do NOT want the list of subscriptions. I want the videos in those subscriptions.
For example, this is the HTML page with the list of videos. It is public, so anyone can access them.
Normally the URLs for getting via a video list through the API look like this.
I've tried different ways of replacing "favorites" or "top_rated" with my collection id, but couldn't get any to work.
You need to get the Channel ID for the subscription/channel your interested in getting.
Then if your using Version 3 of the API you can use 'youtube.search.list' with the following parameters
part: snippet
channelId: [Channel your interested in]
type:video
This will get you the videos in that channel. If your using V2 I think you can use the users feed
http://gdata.youtube.com/feeds/api/users/{userName/ChannelID}/uploads

YouTube API comments streaming

Is there any YouTube API which enables external applications to search for keyword/brand name across all video comments on YouTube and send it back to some URL? Also, pull method is fine if the proposed push idea does not exist.
So I would like to know if my brand was mentioned in any video comment on YouTube, similar as what Twitter allows with User/Site Streams.
The YouTube API (v2.0) defines comments as a property of the video object. Details on this relationship here:
https://developers.google.com/youtube/2.0/developers_guide_protocol_comments?hl=en#Retrieve_comments
Therefore, in order to search every YouTube comment you would need to traverse the entire collection of videos. If you're going to attempt something like this, it makes sense to validate your concept by first focusing on the feeds or categories that are most relevant to your brand. Details on feed and categories here:
https://developers.google.com/youtube/2.0/developers_guide_protocol_video_feeds
https://developers.google.com/youtube/2.0/developers_guide_protocol_category_keyword_browsing
No, there isn't anything like this available from the existing youtube api (neither V2 nor V3)

How do I know if a specific twitter user is online or not?

How do I know if a specific twitter user is currently online by writing programs? Is there any API or data field in the web page showing this information? Both browsing Twitter webpage and using Twitter app are considered "online".
Although this information is not readily available, you can do a work around. Make use of Twitter's Streaming API: https://dev.twitter.com/docs/streaming-apis/streams/public (have a read through this document).
You'll most likely be using the POST Statuses/filter functionality (read the doc here: https://dev.twitter.com/docs/api/1/post/statuses/filter ), which will give you a JSON object with tweets based on your filters.
Make use of the parameters you'll need to specify in the URL to filter the stream (have a look through this document to learn more about it: https://dev.twitter.com/docs/streaming-apis/parameters ), in your case it'll be the follow parameter. You basically specify the twitter ID of the user you want to follow. Here's a sample JSON result of the streaming API in action https://stream.twitter.com/1/statuses/filter.json?follow=25365536 - this one in particular is following Kim Kardashian. Keep in mind that this will give you:
Tweets created by the user.
Tweets which are retweeted by the user.
Replies to any Tweet created by the user.
Retweets of any Tweet created by the user.
So in order to just stream the tweets of your desired user, you'll have to use a programming language of your choice to parse through the JSON object to find the user that actually sent the tweet (this is a little tricky, you'll have to look through the properties of the JSON object to figure it out). Once you narrow the streaming tweets to just the ones from the user though, you can then have an alert on when new tweets by this user stream and that will tell you if the user is online/using twitter at the moment.
It's not clear what you mean by "online" (browsing twitter.com? Using a Twitter app?), but in any case Twitter doesn't provide such information, thankfully.
I'm afraid such information is limited by Twitter and is not available. However you can put your question on https://dev.twitter.com/discussions and ask its developers. Good Luck
you need get user state first
then filter if around current time
then get ids
they are online
use twitter developer api
I do it for my website

Resources