Gracenote GNSDK for ios: video lookup don't return season number - gracenote

I've setup the Gracenote SDK for iOs and successfully made some videos lookup.
I've noticed that for series the sdk correctly return the episode number but don't return season number and for many series.
Here are the logs (Big Bang Theory)
airing start: 2015-10-03T10:05
airing end: 2015-10-03T10:30
channel tui: 251537434
channel tag: F65C41B31CA03052BAD934B93C9ACF57
channel name: NRJ 12
channel callsign: NRJ 12
channel number:
program tui: 556745075
program tag: 63D1515CDA5AD50A6579997F97598833
program title: The Big Bang Theory
program subtitle: La démission de Penny
program seasonNumber: 0
program episode: 13
for:
NSLog(#"program tui: %#", program.tui);
NSLog(#"program tag: %#", program.tuiTag);
NSLog(#"program title: %#", program.officialTitle.display);
NSLog(#"program subtitle: %#", program.subtitle.display);
NSLog(#"program seasonNumber: %lu", (unsigned long)program.seasonNumber);
NSLog(#"program episode: %lu", (unsigned long)program.seasonEpisodeNumber);
Did I missed something ?

You are doing it right. The season data does not exist for this series in your region. A workaround I can think of is do a follow up query using OnConnect API to get the season number.
Here is how: use the program subtitle you received as the query string, specify entityType as "episode" and descriptionLang to your language ("fr" in your case), and make a Program Search method call. Below is the query, FYI.
http://data.tmsapi.com/v1.1/programs/search?q=La+d%C3%A9mission+de+Penny&entityType=episode&descriptionLang=fr&api_key=YOUR_ONCONNECT_API_KEY
About OnConnect API, please visit http://developer.tmsapi.com for more details.
There may be another workaround using another Gracenote API. I will do some research and update this answer.

Related

The API I'm testing sometimes respond with different error codes and questions, how can I used 'Examples' and match assertion to check one OR other? [duplicate]

Files for the scenario
All the files are on same directory.
title-update-request.json
{id: 12, name: 'Old Hello', config:[{username: 'qwe', password: 'tyu'},{username: 'abc', password: 'xyz'}]}
title-update-response.json
{id: 12, name: 'New Hello', config:[{username: 'qwe', password: 'tyu'},{username: 'abc', password: 'xyz'}]}
title-update-error-request.json
{id: 00, name: 'Old Hello', config:[{username: 'qwe', password: 'tyu'},{username: 'abc', password: 'xyz'}]}
title-update-error-response.json
{Error: 'not found', Message: 'The provided Book is not found.'}
book-record.feature
Feature: CRUD operation on the book records.
Background:
* def signIn = call read('classpath:login.feature')
* def accessToken = signIn.accessToken
* url baseUrl
Scenario: Change title of book in the single book-record.
* json ExpResObject = read('classpath:/book-records/title-update-response.json')
* json ReqObject = read('classpath:/book-records/title-update-request.json')
* call read('classpath:/book-records/update.feature') { Token: #(accessToken), ReqObj: #(ReqObject), ResObj: #(ExpResObject), StatusCode: 200 }
Scenario: Change title of book in the non-existing book-record.
* json ExpResObject = read('classpath:/book-records/title-update-error-request.json')
* json ReqObject = read('classpath:/book-records/title-update-error-response.json')
* call read('classpath:/book-records/update.feature') { Token: #(accessToken), ReqObj: #(ReqObject), ResObj: #(ExpResObject), StatusCode: 400 }
update.feature
Feature: Update the book record.
Scenario: Update single book-record.
Given path '/book-record'
And header Authorization = 'Bearer ' + __arg.Token
And header Content-Type = 'application/json'
And request __arg.ReqObj
When method put
Then status __arg.StatusCode
And response == __arg.ExpectedResponse
Actual API response for scenario: 1 is :
{name: 'New Hello', config:[{username: 'abc', password: 'xyz'},{username: 'qwe', password: 'tyu'}]}
Actual API response for scenario: 2 is :
{Error: 'not found', Message: 'The provided Book is not found.'}
Question: How should I validate the response in update.feature file since problem is if I make change s as using #^^config that will not works for scenario :2 and response == _arg.ExpectedResponse is not working for Scenario: 1?
This is classic over-engineering of tests. If someone has told you that "re-use" is needed for tests, please don't listen to that person.
You have two scenarios, one happy path and one negative path. I am providing how you should write the negative path here below, the rest is up to you.
Scenario: Change title of book in the non-existing book-record.
Given path 'book-record'
And header Authorization = 'Bearer ' + accessToken
And request {id: 00, name: 'Old Hello', config:[{username: 'qwe', password: 'tyu'},{username: 'abc', password: 'xyz'}]}
When method put
Then status 400
And response == {Error: 'not found', Message: 'The provided Book is not found.'}
See how clean it is ? There is no need for "extreme" re-use in tests. If you still insist that you want a super-generic re-usable feature file that will handle ALL your edge cases, you are just causing trouble for yourself. See how un-readable your existing tests have become !!
EDIT: Since I refer the question to others often as an example of how NOT to write tests, I wanted to make my point more clear and add a couple of links for reference.
Sometimes it is okay to "repeat yourself" in tests. Tests don't have to be DRY. Karate is a DSL that enables you to make HTTP calls or JSON manipulation in one or two lines. When you start attempting "re-use" like this, it actually leads to more harm than good. For example, you now need to look at multiple files to understand what your test is doing.
If you don't believe me, maybe you will believe the team at Google: https://testing.googleblog.com/2019/12/testing-on-toilet-tests-too-dry-make.html

Stripe API: How do you find the exchange rate and amount in foreign currency of a cross border transfer to a Connect Account?

I'm using Stripe to process payments. I have a platform where international Connect accounts can sell items to others through my platform.
My platform is USD. In this specific example, the Connect account is in CAD (Canada Dollar). When someone purchases an item from this CAD Connect Account, Stripe puts the money in my platform account, leaves my app fee there, and then moves the correct amount into the CAD Connect account. It converts this amount to CAD. In the stripe GUI I can find the exchange rate and amount transferred in CAD, as circled in the screenshot below. But I can't find these attributes in the API.
The only object I've seen with an exchange_rate attribute is the balance transaction. However, when I get the balance transaction for the transaction in the screenshot, I get this response object:
Request: https://api.stripe.com/v1/balance_transactions/txn_1IBNiNLLBOhef2QNqIeaNg9o
Response:
{
"id": "txn_1IBNiNLLBOhef2QNqIeaNg9o",
"object": "balance_transaction",
"amount": -7777,
"available_on": 1611619200,
"created": 1611076199,
"currency": "usd",
"description": null,
"exchange_rate": null,
"fee": 0,
"fee_details": [],
"net": -7777,
"reporting_category": "transfer",
"source": "tr_1IBNiNLLBOhef2QNcNqv3IlS",
"status": "pending",
"type": "transfer" }
The problem here is that the balance transaction object above only shows this transaction in USD: $77.77 USD came out of my platform account.
But it doesn't show the conversion rate or the amount in CAD. When this $77.00 went into the CAD Connect account, as we can see in the GUI screenshot, that $77.77 was converted to $98.02 CAD and the exchange rate was 1.26039 (USD->CAD).
How can I find this CAD amount and exchange rate through the API?
In case you need to know the currency rate before the actual transaction happens they provide the currency rates here
HOWEVER, it's only a frontend page and it requires authorization. On top of that, it's updated once every 12 hours. There is no official API that returns currency rates.
There is a small SaaS product that provides stripe currency rates as a REST API.
https://striperates.com/
The Transfer made to the connected account in this screenshot is in USD. The conversion happens after the Transfer itself. The funds are sent in USD and then in the connected account they get converted to that account's default Currency.
You want to look at the Transfer's destination_payment property which has the py_123 id for the Charge on the connected account. That Charge has a BalanceTransaction object (similar to the Transfer one you shared). That BalanceTransaction would reflect the conversion from USD to CAD and surface the exchange rate used in the exchange_rate property in that case.
In Java you can do
Stripe.apiKey = "sk_live_...";
Transfer transfer = Transfer.retrieve("tr_...");
RequestOptions requestOptions = RequestOptions.builder().setStripeAccount("acct_...").build();
Charge charge = Charge.retrieve(transfer.getDestinationPayment(), requestOptions);
BalanceTransaction balanceTransaction = BalanceTransaction.retrieve(charge.getBalanceTransaction(), requestOptions);
balanceTransaction.getExchangeRate();
balanceTransaction.getNet();
balanceTransaction.getCurrency();
Here is the way I did : I simulated a payment in a foreign currency to a US based account (so that it is presented in US$), then I retrieved the balance transaction associated, and the exchange_rate argument
async function exchangeFeesToUS(currency) {
const paymentIntent = await stripeTestUS.paymentIntents.create({
amount: 10000,
currency: currency,
payment_method_types: ['card'],
customer: "ANY_CUSTOMER_WITH_A_PAYMENT_METHOD",
payment_method: "ANY_CARD_ASSOCIATED_TO_THIS_CUSTOMER",
confirm: true
});
return await balanceTransaction(paymentIntent).then(balance => {
return balance.exchange_rate
})
}
async function balanceTransaction(paymentIntent) {
const chargeId = paymentIntent.charges.data[0].id;
const charge = await stripeTestUS.charges.retrieve(
chargeId
);
return await stripeTestUS.balanceTransactions.retrieve(
charge.balance_transaction
);
}
Now, if you want to convert to another currency than the US$, just call the aforementioned function twice :
async function exchangeFeesToCUSTOM_CURRENCY(currency) {
const rate = await exchangeFeesToUS(currency)
const rateCUSTOM_CURRENCY = await exchangeFeesToUS('your_custom_currency')
return rate / rateCUSTOM_CURRENCY
}

preview is not working for actions-on-google, web & device

Having trouble getting my action to work in preview.
After installing the app on gcloud I ran....
./gactions preview -action_package=agent.json -invocation_name="my action"
... and I got...
Pushing action 'my action' for testing...
'my action' is now available for you until 2017-04-08 9:32AM CDT (29 minutes from now)
Try 'gactions simulate', then 'talk to my action', or use the Web Simulator at https://g.co/actionswebsim.
Then I ran...
./gactions simulate
.. and I got...
User TTS (CTRL-C to stop):
Than from the device I got...
Sorry I don't know how to help with that...
And from the web simulator I got....
{
"response": "Sorry, this action is not available in simulation",
"audioResponse": "//NExAASq..."content_copy,
"debugInfo": {
"sharedDebugInfo": [
{
"name": "GOOGLE_SYSTEM_ACTION",
"debugInfo": "Your query is handled by Google’s system actions"
}
]
}
}
Any ideas?
Thanks,
Don
In order for the simulator to invoke your intent, you have to begin with "talk to your invocation name" or "at your invocation name for deep link phrase"
More details here:
https://developers.google.com/actions/distribute/invocation-and-discovery
It works for me.
Just type excatly the following 'talk to my test app'

Can't filter Firebase model with REST API

I'm trying to use Firebase's REST API to only retrieve episodes with a specific Podcast API. The curl request is returning all the episodes in the database, not just the ones where podcastID="863897795"
Here's the first query I tried:
curl https://myurl.firebaseio.com/episodes.json?orderBy=\"podcastID\"&equalTo="863897795"
and here's the second:
curl https://myurl.firebaseio.com/episodes.json?orderBy=\"podcastID\"&endAt="863897795"&startAt="863897795"
Here's my model:
episodes
b44dfeb16d5feb75d592d2f21b605cbb
downloadURLString: "http://traffic.libsyn.com/timferriss/Tim_Ferris..."
duration: 0
fileType:
"audio/mpeg"
podcastID:
"863897795"
publishDate:
1456271851
summary:
"This episode is a special double header. It fea..."
title:
"Kaskade and Sekou Andrews: The Musician and the..."
f68ee7bd673662a5b416577536ea8e6d
downloadURLString:
"http://starbucks.podspot.de/files/starbucks_cof..."
duration:
0
fileType:
"audio/mpeg"
podcastID:
"218302289"
publishDate:
1226305317
summary:
"Das \"Coffee and Crime\" Krimi-Festival in Kooper..."
title:
"Starbucks Special - Coffee and Crime Festival R..."
Here's my indexing:
"episodes": {
".indexOn": ["podcastID"]
}

In Meteor, how can I publish a single object from an array field?

I have the following Mongo collection:
{
id: '123456',
name: 'GameXYZ',
reviews: [
{createdBy: 'Bob', score: 5}, {createdBy: 'John', score: 8}
]
}
I would like to create a publish function that returns only the review created by Bob:
{
reviews: [
{createdBy: 'Bob', score: 5}
]
}
I've tried this:
return myCollection.find({'reviews.createdBy': 'Bob'}, {'reviews.$': 1});
The problem is Meteor returns the entire document. According to their documents, "Field operators such as $ and $elemMatch are not available on the client side yet."
My function is running on the server, so I don't know why it's not working. It does work on the Mongo Shell.
My question is: could anyone recommend a way to publish only that single object of the array, in Meteor?
This is best done like the comments example from discover meteor. Create new collection reviews. You can put what ever you need in it but it has to have the id of what ever it's a review of. That way you can publish and find it with reviews.find({reviewsId: the id of the collection; in this case 123456})

Resources