Youtube API get feed ignore duplicates - api

I cannot find a way of getting youtube to not return duplicate videos in a feed.
I am currently using API v1 and I understand that v2 and v3 are where I should be moving too. I am using ZF 1 and its Gdata library not that it should matter if there is API level support for what I want to do.
However I cannot see the solution in either of those versions either.
Heres whats happening.
For some reason the server code is occasionally uploading duplicate videos in parallel.
Youtube detects that and then it seems to list a video on the feed as duplicate and it wont play.
https://gdata.youtube.com/feeds/api/users/username/uploads/?max-results=50
So I get 50 videos from that users account. Is there anyway to tell youtube, dont return videos that are duplicates.
I mean it almost seems obvious that it shouldnt right?
Does anyone know anything about filtering duplicates out of feeds?
I look at the data returned and theres no indication of a status or any other info which would provide me with a way to tell a clip is duplicate.
Hopefully someone knows the solution.
Cheers!

Both in V2 and V3 you got the status "rejected". Have you checked if this might be also in V1?

Okay, so I worked it out, turns out theres a state property which you can interrogate in the feed. See the code below to know how to check the state and ignore it if its been rejected.
Damn Zend Framework v1 Documentation is pretty much non-existent for this kind of thing.
$applicationId = 'App ID';
$clientId = 'Client ID';
$youtubeDeveloperKey = 'Developer Key';
$token = unserialize($gdata_oauth_access_token);
$httpClient = $token->getHttpClient($this->_oauthOptions);
$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $youtubeDeveloperKey);
$url = 'https://gdata.youtube.com/feeds/api/users/' . $youtube_user_name . '/uploads/?max-results=50';
$videoFeed = $yt->getVideoFeed($url);
// process the feed
foreach ($videoFeed as $videoEntry) {
$state = $videoEntry->getVideoState();
if (is_object($state) && $state->name == 'rejected') {
// skip this video
continue;
}
}

Related

Issue with page_info and products.json

I'm a developer working on a private app to manage the database and the inventory of a Shopify Online Store with Symfony and I'm looking for getting all products or inventory of the store.
I tried with the url https://{{api_key}}:{{password}}#{{shopify_domain}}/admin/products.json , but it gets only 50 to 250 products and there's more than 200 000 products on this online Store. I also tried with /admin/inventory_items, but it returns missing or invalid parameter.
Recently, I checked the documentation of cursor-based pagination and I saw that there's a parameter call page_info but I didn't know how to get it. So after many researches, I learned that I had to find the parameter on the last product displayed to go to the next product which will be on the next page. I also seen that there was a parameter on GraphQL which is called storefrontId, it looked like page_info so I tried to add it to the URL but it didn't worked. I noticed that there were a = to the end of the URL, so I tried it with =0 =1 =2 and =3, also with =rel=next =next and =page=2 but it returns the same error : { "errors": { "page_info": "Invalid value." } }
For people who will find me a solution with downloading data and uploading it daily, this is not relevant because on this online store there is more than 200 000 products and the employee aren't developer.
If there is a possibility to update and display the database in real-time, without uploading a file, it would be perfect !
If you know how to help me, I'm open to suggestions !
Thanks,
Karim HADJ-ABDELKADER
The parameter page_info should be unique ID and not just number, look at this docoment about the pagination paramenters
https://shopify.dev/docs/api/usage/pagination-rest#parameters
for example :
https://{shop}.myshopify.com/admin/api/2019-07/products.json?page_info=hijgklmn&limit=3

youtube API 3 - get all data in single request

I am using YouTube API 3 to fetch video results for which I have to make two http requests which are sequential not parallel.
1- First API call is to get youtube video ids for a search term.
https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&q=QUERY_TERM&key={API KEY}
2- From first I am preparing a list of comma separated video IDs (ALL_VIDEO_IDS) and fetching individual video details like duration, viewcount etc.
https://www.googleapis.com/youtube/v3/videos?id=ALL_VIDEO_IDS&part=contentDetails,statistics&key={API KEY}
Actually I want a way so that I can get all these details in one call rather than two. How to achieve this?
Is there a way to achieve it which I don't know or I am missing something?
Here it is, with example of getting video duration,
but do not forget to create your API key at https://console.developers.google.com/project
$vidkey = "cHPMH2sa2Q" ; video key for example
$apikey = "xxxxxxxxxxxxxxxxxxxxx" ;
$dur = file_get_contents("https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id=$vidkey&key=$apikey");
$VidDuration =json_decode($dur, true);
foreach ($VidDuration['items'] as $vidTime)
{
$VidDuration= $vidTime['contentDetails']['duration'];
}

Rally print stories with parent feature name in the card generated

I've used Joel Krooswyk's Print All Backlog Story Cards solution for printing all stories in a backlog.
What I'd like to do is to extend this to have each card print the name of the parent feature that the card belongs to so I can print them all up and lay them on a table for a collaborative estimation session.
The issue is, I'm having trouble finding how to do it.
A snippet of his code in question:
queryArray[0] = {
key: CARD_TYPE,
type: 'hierarchicalrequirement',
query: '((Iteration.Name = "") AND (Release.Name = ""))',
fetch: 'Name,Iteration,Owner,FormattedID,PlanEstimate,ObjectID,Description,UserName',
order: 'Rank'
};
I can't seem to find the element to fetch!
Parent was listed on an example queries page(intended for use in the browser query functionality), with Parent.Name containing the actual text but so that hasn't worked - trying to find a reference that is clear about it seems to be eluding me.
I've looked at the type definition located at:
https://rally1.rallydev.com/slm/webservice/v2.0/typedefinition/?fetch=ObjectID&pagesize=100&pretty=true
Going to the hierarchical requirement's type definition from that page indicates it has a Parent field in one form or another.
I'm not even sure that that one will solve what I'm looking at.
A bit stuck, and I'm not sure what I'm trying to do is even possible with the hierarchical requirement object type.
Note: I assume even if I do find it I'll need to add some code to deal parentless stories- not worried about that though, that's easy enough to deal with once I find the actual value.
Many thanks to anyone who can help :)
I modified Joel's app to include PI/Feature's FormattedID to the cards when a story has a parent PI/Feature.
You may see the code in this github repo.
Parent field of a user story references another user story.
If you want to read a parent portfolio item of a user story, which is a Feature object, use Feature attribute or PortfolioItem attribute. Both will work:
if (data[i].PortfolioItem) {
//feature = data[i].PortfolioItem.FormattedID; //also works
//feature = data[i].Feature.Name; //also works
feature = data[i].Feature.FormattedID;
} else {
feature = "";
}
as long as the version of API is set in the code to 1.37 or above (up to 1.43).
PrintStoryCards app is AppSDK1 app.
1.33 is the latest version of AppSDK1.x
1.29, which the app is using is not aware of PortfoilioItems.
PortfolioItem was introduced in Rally in WS API version 1.37.
See API versioning section in the WS API documentation .
If you want to access Portfolio Items, or other features introduced in later versions of WS API up to 1.43 this syntax will allow it.
<script type="text/javascript" src="/apps/1.33/sdk.js?apiVersion=1.43"></script>
This has to be used with caution. One thing that definitely will break is around calculations of timebox start and end dates. That's why many legacy Rally App Catalog apps are still at 1.29.
This is due to changes in API Version 1.30.
Note that this method of setting a more advanced version of WS API for AppSDK1 does not work with v2.0 of WS API.
You should be able to add PortfolioItem to your fetch. Parent is the field used if the parent is a story. PortfolioItem is the field used if the parent is a Feature (or whatever your lowest level PI is).
Then in the results you can just get it like this:
var featureName = (story.PortfolioItem && story.PortfolioItem.Name) || 'None';

What is the simplest way to display Instagram follower count

I am using WordPress and trying to figure out the simplest way to display the amount of Instagram followers a user has.
Whilst searching I have found a few Instagram PHP wrapper scripts that seem a little overkill for what I am trying to display.
From reading through the Stackoverflow posts I came across a post that listed this code:
$userinfo = wp_remote_get("https://api.instagram.com/v1/users/3955450?access_token=f0d225aa955c4bd9ae563f87f831efab");
$userinfo = json_decode($userinfo);
$followers = $userinfo['data']['counts']['followed_by'];
echo "Folled by: " . $followers . " people";
This is a simple and perfect script HOWEVER it does not return any data.
I have setup a client on the Instagram Developer site however I cannot get the above script to display any data.
Any help would be greatly appreciated.
Try this:
$result = file_get_contents("https://api.instagram.com/v1/users/3955450?access_token=f0d225aa955c4bd9ae563f87f831efab");
$obj = json_decode($result);
echo $obj->data[0]->id;

Ektron Workarea

I need to develop an application that extracts all the contents in Content Tab of the Ektron Workarea and I have to keep tree structure of folders (taxonomies,collections,forms,etc.) also.When I click the content I need to get the Content ID in the code behind also.I need to do all these in a single function.
I tried this requirement with the concept of content block widget in workarea.When we drag that widget and edit it a pop up will come and it displays the folders of work area in tree structure.But when I created an aspx page, put the same code and I browse that page I didn't get the tree structure of all contents.Only the main tabs(Folders,Taxonomies and search ) are visible.Then I drag the user control in the aspx page .But it also doest work.
So how will I solve the above problem.
Can I pull all the contents in tree structure from work area from the root using API codes?.Then can anyone please give the API code to solve?
Please anyone reply!
Assuming you are using 8.6 look here to start with:
http://reference.ektron.com/developer/framework/content/contentmanager/getlist.aspx
Update:
I think I misread your question the first time around. Allow me to expand on my answer a bit. My original answer with the web services assumes that you are rendering the content tree from some sort of "presentation tier" -- a different web site, a console app, or a WPF/WinForms app, etc.
You can get the recursive folder structure with something like this:
private FolderData GetFolderWithChildren(long folderId)
{
var folderApi = new Ektron.Cms.API.Folder();
var folderData = folderApi.GetFolder(folderId);
// This next method is marked as obsolete in v9.0;
// a newer overload is available in v9.0, but I
// don't know if it's available in v8.0
folderData.ChildFolders = folderApi.GetChildFolders(folderId, true);
}
I'm a little confused as to what exactly you're trying to accomplish. If you want to show the entire tree structure graphically, have you tried taking the code and markup from the edit view of the content widget and using it on your non-edit view?
I must say, your requirement that "I need to do all these in a single function" worries me a bit. Workarea content trees can get really large very quickly. If you're trying to load all of the folders and all the taxonomies and all the collections, etc. Then the user will likely be waiting a long time for the page to load, and you risk running into timeout issues.
-- Original Answer --
Ektron v8.0 doesn't have the 3-tier option, which is too bad because that would really make your job a lot easier. In v8.0, there are ASMX web services that you can reference, including:
/workarea/webservices/content.asmx
/workarea/webservices/webserviceapi/user/user.asmx
There are lots more than this; browse through the folders within /workarea/ to see what's available.
It's been a while since I've worked with these services, so I'm a little rusty...
Suppose you add references to those two services I listed above and name them ContentService and UserService. The first thing you'll want to do is set the authentication headers. Then you can call the service methods in much the same way as the old legacy apis.
var contentApi = new ContentService.Content();
contentApi.AuthenticationHeaderValue = new ContentService.AuthenticationHeader();
contentApi.AuthenticationHeaderValue.Username = username;
contentApi.AuthenticationHeaderValue.Password = password;
contentApi.AuthenticationHeaderValue.Domain = domain;
var userApi = new UserService.User();
userApi.AuthenticationHeaderValue = new UserService.AuthenticationHeader();
userApi.AuthenticationHeaderValue.Username = username;
userApi.AuthenticationHeaderValue.Password = password;
userApi.AuthenticationHeaderValue.Domain = domain;
var ud = userApi.GetUserbyUsername("jimmy456");
long folderID = 85;
bool recursive = true;
ContentData[] folderContent = contentApi.GetChildContent(folderID, recursive, "content_id");