Downloading YouTube video information, used to work, now not so much - vb.net

I used to have some code for downloading youtube data and processing it and everything worked fine until google changed something. Was around the time they changed it from 1 channel per account to as many as you want.
This is a sample of the feed that I would download and process but I can’t seem to get it working.
feedUrl = http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/uploads
The code I would use to process it looks like this;
Dim videoFeed As Feed(Of Video) = request.[Get](Of Video)(New Uri(feedUrl))
In the references section, I used to have v2.1 of the google.GData.YouTube, .Extensions & .Client addons and I have updated them to 2.2.
I tried changing the code that processes the line to this but it still doesn’t work.
Dim videoFeed As Feed(Of Google.YouTube.Video) = request.[Get](Of Google.YouTube.Video)(New Uri(feedUrl))
The code runs over the line ok, it’s when it tries to use videoFeed, it throws the error.
intTotalVideos = videoFeed.TotalResults
The error I get is as follows;
Execution of request failed: http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/uploads
I don’t know what changed on the google side, maybe it was the new v3 API or the way you log in via code changed when they let you have multiple channels per account.
If anyone has any advice or where I can find more information, it would be greatly appreciated.
(I tried to find the original code on the net that I used to create the project but was unable to find it sorry.)

According to Developer's Guide: .NET:
The YouTube Data API (v2) has been officially deprecated as of March
4, 2014. Please refer to our deprecation policy for more information.
The following V2 example works for me:
Dim settings As New YouTubeRequestSettings(applicationName, developerKey)
Dim request As New YouTubeRequest(settings)
Dim videoFeed As Feed(Of Video) = request.[Get](Of Video)(New Uri(feedUrl))
Dim intTotalVideos As Integer = videoFeed.TotalResults
Google YouTube SDK .Net Library with version 2.2.0 is used.

Related

Azure mobile app with existing sql backend

I have been following these examples in a previous stack overflow example, I need to convert to an Integer id to an Azure mobile app, and need a MappingDomainManager class described by user Kiske1 in the post below.
Azure Mobile App using existing database
However, I have been unable to complete this as Automapper.impl.PropertyAccessor is “Type of namespace Impl does not exist…” I am using the latest Automapper dll v6.1.1.0.
Does anyone know where PropertyAccessor has been moved to/or replaced with?
Also, both examples that were specified in this post are from 2014, does anyone know of a more up to date walkthrough and preferably an example project?
Does anyone know where PropertyAccessor has been moved to/or replaced with?
I searched at AutoMapper project and found that PropertyAccessor has been removed. Also, I checked my mobile app project and the Automapper version is 3.3.1, the PropertyAccessor exists and the old sample could work. I assumed that you could try to downgrade the version of your Automapper to fix this issue.
does anyone know of a more up to date walkthrough and preferably an example project?
For Automapper 6.1.1, the usage for FindTypeMapFor method and the parameter type for GetExistingPropertyMapFor method have changed, you could modify your code under SimpleMappedEntityDomainManager as follows:
var m = Mapper.FindTypeMapFor<TModel, TData>();
m.GetExistingPropertyMapFor(new PropertyAccessor(typeof(TData).GetProperty("Id")));
To
var m = Mapper.Configuration.FindTypeMapFor<TModel, TData>();
m.GetExistingPropertyMapFor(typeof(TData).GetProperty("Id"));
Moreover, you could refer to adrian hall's book about The Domain Manager.

Kivy app (on android) crashes when attempting to use google directions api

I new to Kivy (and relatively new to Python) and I am having a problem getting UrlRequests to work. In particular, I am trying to use the google directions api in an App for android.
First of all, the code works (completely) when I run the main.py file through python.
The app also successfully builds and deploys to my phone using buildozer. The app loads and runs right up to the point where you press a button to launch a urlrequest, at which point the app just closes.
So I believe the problem is this button. The full details of the button are somewhat unnecessary to explain now I think, but basically it uses a function (like below) several times to return the distance between places.
import urllib2
#the google api key
google_api_key = '...'
def distance_checker(origin, destination):
# This function outputs the distance between two places in meters
api_key = google_api_key
url = 'https://maps.googleapis.com/maps/api/directions/json?origin='
start = origin.replace(' ', '%20')
end = destination.replace(' ', '%20')
final_url = url + start + '&destination=' + end + '&mode=walking' + '&key=' + api_key
json_obj = urllib2.urlopen(final_url)
data = json.load(json_obj)
return data['routes'][0]['legs'][0]['distance']['value']
In my buildozer.spec file I do have 'android.permissions = INTERNET' included.
I also had my app attempt to access google using a function of the form (submitted by user: 10flow, on Pinging servers in Python),
import os
def ping_function(self):
hostname = "google.com" #example
response = os.system("ping -c 1 " + hostname)
#and then check the response...
if response == 0:
self.box.add_widget(Label(text=(hostname + ' is up!'), size_hint_y=None, height=40))
else:
self.box.add_widget(Label(text=(hostname + ' is down!'), size_hint_y=None, height=40))
For clarity, the 'box' used above is for a ScrollView widget. This function does work in the app in android (i.e. it does create a Label saying 'google.com is up!'). So this would lead me to believe that accessing the internet itself is not the problem: the problem is either using a google api, or the using of urllib2 (that make sense?).
I also wrote a function which does the url query using UrlRequest instead of urllib2, but that had the same problem in the end (works on linux, not on android).
So I imagine the problem is using google apis. And I think it has something got to do with adding 'google-play-services_lib/' as an android.library reference in the buildozer.spec file.
If what I have said so far makes sense, could anyone comment on the google api/google-play-services_lib issue? I'm really not that familiar with apis in general, and am somewhat out of my depth. Or perhaps this isn't the issue, and I have missed something obvious.
Anyway, thanks in advance.
EDIT
I think I have narrowed down the problem somewhat. I can use apis that do not require a key, and I cannot use apis that do need a key. Posts like How to get google map apikey in android lead me to believe I just need to add the google api key (in the case of the google directions api) to the android meta data in the buildozer.spec file. I have unsuccessfully tried several variations of the following,
# (list) Android application meta-data to set (key=value format)
android.meta_data = com.google.android.maps.v2.API_KEY=AI...
If anyone could tell me what I am doing wrong it would be very helpful!
Thanks.
So for others and posterity, I found an answer through the Kivy users forum (http://kivy.org/#forum, question: Problems with UrlRequest with an api that needs an api key).
The issue was I was trying to access a https url, and hence needed to build the android apk using openssl. No need for android meta data or google play services, just add openssl to the requirements in the buildozer.spec file.
requirements = openssl,kivy
Once it was discovered that openssl was the issue, there was one more problem to overcome in that buildozer attempted to download an openssl tar file that no longer existed on the openssl.org webpage. However, one can edit the openssl version buildozer attempts to download in your_project/.buildozer/android/platform/python-for-android/recipes/openssl/recipe.sh . You will also need to update the MD5 value in that file.
Hopefully this helps someone in the future.

Visual Basic twitter app using Linq2twitter library?

I am using Linq2twitter library in Visual Basics to build a twitter app that will monitor my twitter feed and communicate with my Arduino (via COM) to perform a certain action whenever i tweet something!! I am new to Visual Basics and Application Programming Interface so i am trying to learn from the basics!! After hard work and research I created a simple GUI(having a button and a richtextbox) wrote some codes and i was able to tweet!! My 1st code was something like this
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim credentials As IOAuthCredentials = New InMemoryCredentials
credentials.ConsumerKey = "xxxx"
credentials.ConsumerSecret = "xxxx"
credentials.OAuthToken = "xxxx"
credentials.AccessToken = "xxxxx"
Dim auth As PinAuthorizer = New PinAuthorizer()
auth.Credentials = credentials
Dim twitterCtx As TwitterContext = New TwitterContext(auth)
twitterCtx.UpdateStatus(Box1.Text) 'Box1 is the richtextbox
End Sub
This code worked :)
Now i want a twitter homepage feed
So after a long research i was able to write the following code
Dim auth As PinAuthorizer = New PinAuthorizer()
auth.Credentials = credentials
Dim twitterCtx As TwitterContext = New TwitterContext(auth)
Dim tweets = From tweet In twitterCtx.Status
Where tweet.Type = StatusType.Home
Now how do i make the "tweet" display on another textbox i made?? :S Will this code work?? There are very few examples of vb using Linq2twitter and having no idea of how this library is used made it a real pain in the butt to write these codes. And How am i doing?? Is this the write way?? How can i learn faster and better??
Please leave your suggestions!! And I found out twittervb.dll library was easier to use but it didn't work for me! I don't know why!! I got a flood of exception errors...and i have set my application settings to Read, Write and DirectMessages !! Thanks in advance :)
There is a LinqToTwitterDemoVB project in the downloadable source code with VB samples. My VB samples are growing, but I have a lot of pending requests for samples for multiple technologies and scenarios and it will take a while to reach all the samples I want to include. My Documentation is mostly in C#, but once you see how a couple C# queries translate into VB, you will be able to figure out the rest of the commands and queries.
LINQ to Twitter is a 3rd party library that lets you use LINQ to communicate with Twitter. You use it to either Tweet, as in the UpdateStatus you have working, or to query Twitter. When you query Twitter, you'll get a response that depends on the type of query. That response is data that you can use in your application. Once you have the data, LINQ to Twitter has performed its work and you are responsible for writing the code that uses that data.
The query above, for the Home Timeline, looks fine. Now you have tweets, which is a collection of Status. First, you'll need to learn how to display a collection of objects with VB for the technology you're working with. Once you've figured that out, you'll know how to display the collection of Status that LINQ to Twitter gives you.

Google+ .Net API - Getting Authenticated and retrieving profile

I'm trying to get a users profile information for google+ via the .NET API but am having trouble.
Does anyone know if they have changed how the special ID "me" works?
In the documentation it says this can be used as a special ID to get the currently authenticated users information however this throws a 404 from both the API in my code and on Google's own test page https://developers.google.com/+/api/latest/people/get. I was logged in when trying this.
Does anyone know how to get the user ID as I would happily use that instead of me but it isn't returned after the user authenticates as far as I can see (just an authcode)?
I also tried using user IDs returned when using the standard .net Oauth stuff but it isn't the correct ID, I assume it is for something else.
As for my method of getting to this stage, I first downloaded the example files here: http://code.google.com/p/google-api-dotnet-client/wiki/GettingStarted
They don't have a plus example so I took the Tasks.ASP.NET.SimpleOAuth2 example and swapped out tasks (which worked fine) for the plus equivalent.
I also tried rolling this into my own project.
Neither worked. I get the user forwarded to Google where they give me access fine and then when I return they are authenticated successfully as far as I can see, however when I call service.People.Get("me") it returns a 404.
If anyone could help with the above questions (using me, or gettign the user ID) I would appreciate it.
To the moderator who closed the initial version of this question, I have tried to make this as direct a question as possible so please don't close it. This is a legitimate question I would really like help getting to he bottom of.
This is now out of date given recent platform updates. Although the plus.me scope still exists and this code will work, you should be using the plus.login scope for retrieving profile data in C#. For a great way to get started with retrieving and rendering profile information, please start from the Google+ C# quick start available here:
https://developers.google.com/+/quickstart/csharp
First off, the 'me' id still works and is unchanged. The way that it works is:
You authenticate the user using a standard OAUTH2 flow
You use the library to perform a People.get with the special value 'me'
The 404 error code is a little troubling, this means that the client isn't finding the endpoint. To debug this, you might want to use a packet sniffer like fiddler to see what the actual URL it's querying is.
Anyways, how about some C# code. The following example shows how to use the plus service to get the currently authenticated user (assuming you have authenticated someone). What's different from your snippet is that you need to form a get request for the API call, then run fetch on the get request. I've included the following example, for getting 'me', and the following code works:
var auth = CreateAuthenticator();
plusService = new PlusService(auth);
if (plusService != null)
{
PeopleResource.GetRequest prgr = plusService.People.Get("me");
Person me = prgr.Fetch();
}
All of the configuration of the server and getting a client working is pretty hard and pasting all of the code here would be less helpful than just giving you a sample.
And so... I have written a sample application that demonstrates how to do this and also includes a wrapper that makes it easier to develop using the Google+ API in C#. Grab it here:
Google+ C# Server-Side demo and library
Seems you need to use:
Person test = service.People.Get("me").Fetch();
and not
req = service.People.Get("me");
Person test = req.Fetch();
Even though they seem to be identical the first works and the second doesn't.
Still not sure why google's own page doesn't work though. Now to find out how to add things to the scope like birthday.

Zend_Gdata_ClientLogin::getHttpClient Issues

I am working on a project using the Youtube APIv2.
I am using the API through Zend Framework via Zend Gdata.
My application is querying the youtube api, getting a video feed then for each entry getting the name, thumbs, views, duration and tags for each video entry.
As announced by Google (http://apiblog.youtube.com/2012/08/video-tags-just-for-uploaders.html) now to get the video tags of each video entry the youtube api request as to be authenticated by the user that owns the videos on youtube in order to retrieve these video tags.
What i've done is simply adding a developer key and a httpClient object when I init the *Zend_Gdata_YouTube* object, like that :
$developerKey = 'mydevkey';$authenticationURL = 'https://www.google.com/youtube/accounts/ClientLogin';$idApplication = 'my_app_id';$idClient = null;$httpClient = Zend_Gdata_ClientLogin::getHttpClient( $username = 'google_account_email', $password = 'google_account_pass', $service = 'youtube', $client = null, $source = 'my_app', $loginToken = null, $loginCaptcha = null, $authenticationURL);$this->yt = new Zend_Gdata_YouTube($httpClient, $idApplication, $idClient , $developerKey);$this->yt->setMajorProtocolVersion(2);
I tested this piece of code in my project locally inside Mamp Pro and it works perfectly fine, retreiving the video tags as it should be, meaning that the code works.
My problem starts when i wan to put my code on my production server, the *Zend_Gdata_ClientLogin::getHttpClient* object is not working and keeps giving me the error code "Authentication with Google failed. Reason: BadAuthentication"
I checked if someone else was having my problem and i came to this article "http://apiblog.youtube.com/2011/03/clientlogin-fail.html", but neither of the 4 scenarios are similar to my problems.
Could someone help me ? Does my production server is missing something in terms of modules or authorizations (i check it doesn't looks like it).
Thank you.
I had the same problem. My script was working locally, but not in production.
Change your password for a new one and run your script in production first.