Freebase - get Movies AND TV Shows by Artist - freebase

I am currently doing this:
var que = '[{\
"id": "' + id.id + '",\
"name": null,\
"/film/actor/film": [{\
"film": null,\
"id": null,\
"character": null,\
}]\
}]';
var json = JSON.stringify(eval("(" + que + ")"));
var films = new Array();
var url2 = 'https://www.googleapis.com/freebase/v1/mqlread?query=' + json;
$.getJSON(url2,function(data){
films = data.result[0]["/film/actor/film"];
for (x=0; x<films.length;x++){
var title = films[x].film;
var id = films[x].id;
$("#movies").text($("#movies").text() + title + ",");
}
})
And it works fine so far, but when i check the result, it only includes the Movies an Actor or Actress performed in, how can i include or request all the TV Shows as well?

Include the necessary types and properties for TV Shows and TV Actors, in addition to the film actor properties that you have included now.

Related

Xamarin forms - Country by Location

I'm trying to get the country of the user using the location. Is there a library or API that can help me with this? And if not, where do you think I can start?
Thanks,
this is called "Reverse Geocoding" and can be done using Essentials
var lat = 47.673988;
var lon = -122.121513;
var placemarks = await Geocoding.GetPlacemarksAsync(lat, lon);
var placemark = placemarks?.FirstOrDefault();
if (placemark != null)
{
var geocodeAddress =
$"AdminArea: {placemark.AdminArea}\n" +
$"CountryCode: {placemark.CountryCode}\n" +
$"CountryName: {placemark.CountryName}\n" +
$"FeatureName: {placemark.FeatureName}\n" +
$"Locality: {placemark.Locality}\n" +
$"PostalCode: {placemark.PostalCode}\n" +
$"SubAdminArea: {placemark.SubAdminArea}\n" +
$"SubLocality: {placemark.SubLocality}\n" +
$"SubThoroughfare: {placemark.SubThoroughfare}\n" +
$"Thoroughfare: {placemark.Thoroughfare}\n";
Console.WriteLine(geocodeAddress);
}

I need help for woocommerce integration in google sheet through web hook

I just attach my woocommerce through webhook in google sheet and get some code from internet for getting orders data on it every things looks fine but there is only one product name available even if the order contain more than one products.You can check the webhook data here when order is created. here is my google sheet script code
//this is a function that fires when the webapp receives a GET request
function doGet(e) {
return HtmlService.createHtmlOutput("request received");
}
//this is a function that fires when the webapp receives a POST request
function doPost(e) {
var myData = JSON.parse([e.postData.contents]);
var order_created = myData.date_created;
var product_name = myData.line_items[0].name;
var itemName = myData.line_items[0].name;
var quantity = myData.line_items[0].quantity;
var product_items = quantity + " x " + itemName + "\n";
var product_qty = myData.line_items[0].quantity;
var order_total = myData.total;
var billing_email = myData.billing.email;
var billing_first_name = myData.billing.first_name;
var billing_phone = myData.billing.phone;
var shipping_address = myData.shipping.address_1;
var timestamp = new Date();
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow([timestamp,order_created,billing_first_name,billing_phone,shipping_address,product_name,product_qty,order_total,billing_email,product_items]);
}
You are trying to loop through sone JSON transaction data that includes multiple line items.
There are two flaws in your code:
1 - the script does not loop through the product items:
var product_name = myData.line_items[0].name;
var itemName = myData.line_items[0].name;
var quantity = myData.line_items[0].quantity;
var product_items = quantity + " x " + itemName + "\n";
var product_qty = myData.line_items[0].quantity;
You are getting line_items[0], but if there are multiple line items in the transaction then you are only ever returning the first line item.
2 - The variables being appended in sheet.appendRow() need to be re-considered.
Your code specifies ten variables, including product name and product quantity. However there are no unique values for these two variables since they are form part of the line items and vary with each line item in the transaction.
Your variable product_items is an attempt to recognise this by concatenating the details for each line item; however the variable fails because it depends on looping through the line_items AND progressively concatenating line item values.
The following code is an example of how you might achieve your outcome:
function doPost(e) {
var myData = JSON.parse([e.postData.contents]);
var timestamp = new Date();
var order_created = myData.date_created;
var billing_first_name = myData.billing.first_name;
var billing_phone = myData.billing.phone;
var billing_email = myData.billing.email;
var shipping_address = myData.shipping.address_1;
var order_total = myData.total;
var lineitems=""
for (i in myData.line_items)
{
var product_name = myData.line_items[i].name;
var itemName = myData.line_items[i].name;
var quantity = myData.line_items[i].quantity;
var linetotal = myData.line_items[i].total;
var product_items = quantity + " x " + itemName + ":$"+linetotal +"\n";
var lineitems =lineitems+product_items;
}
Logger.log("Timestamp: "+timestamp);
Logger.log("Order created: "+order_created);
Logger.log("Billing first name: "+billing_first_name+", Phone: "+billing_phone+", Email: "+billing_email);
Logger.log("Shipping Address: "+shipping_address)
Logger.log("Line items = "+lineitems);
Logger.log("Order Total: "+order_total)
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow([timestamp,order_created,billing_first_name,billing_phone,shipping_address,order_total,billing_email,lineitems]);
}

Is there a way to use a script to pull a date from a Google Form submission from sheets into Gmail?

I have no experience with script writing, but I was able to find a script and edit it (with lots of trial and error) to fit my need.
I have a Google Form where the first question allows users to select a date, but it is not necessarily the date users are completing the form. The results export to a Google Sheet, and I have a script that sends an email with the form responses.
It worked beautifully until Daylight Savings Time. Now, the dates in the spreadsheet are correct, but in the emails they are one day off.
Example email message:
Your child, NAME, received a dress code violation on Wed Mar 27 2019
23:00:00 GMT-0600 (CST), for No ID.
Before Daylight Savings Time, the time was showing as 00:00:00.
In the code, row[2] is the date pulled from the spreadsheet.
var EMAIL_SENT = "EMAIL_SENT";
function sendEmails2() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Script");
var startRow = 2;
var numRows = 5000;
var dataRange = sheet.getRange(startRow, 1, numRows, 5000)
var data = dataRange.getValues();
for (var i = 0; i < data.length; ++i) {
var row = data[i];
var emailAddress = row[12];
var message = "Your child, " + row[10] + ", received a dress code violation on " + row[2] + ", for " + row[11] + ".\nIf you have any questions, please email NAME at name.name#name.org\n\nThank you,\n\nNAME\nAssistant Principal";
var emailSent = row[13];
if (emailSent != EMAIL_SENT) {
var subject = "Uniform Violation - Do Not Reply";
MailApp.sendEmail(emailAddress, subject, message);
sheet.getRange(startRow + i, 14).setValue(EMAIL_SENT);
SpreadsheetApp.flush();
}
}
}
Ideally, the email would provide the date exactly from the spreadsheet in MM/DD/YYYY format.
Instead, the emails show the previous day with the time of 11 pm.
Try this:
var EMAIL_SENT = "EMAIL_SENT";
function sendEmails2() {
var ss=SpreadsheetApp.getActive();//added this
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Script");
var startRow = 2;
var numRows = 5000;
var dataRange = sheet.getRange(startRow, 1, numRows, 5000)
var data = dataRange.getValues();
for (var i = 0; i < data.length; ++i) {
var row = data[i];
var emailAddress = row[12];
var message = "Your child, " + row[10] + ", received a dress code violation on " + Utilities.formatDate(new Date(row[2]),ss.getSpreadsheetTimeZone(), "MM dd, yyyy HH:mm:ss" ) + ", for " + row[11] + ".\nIf you have any questions, please email NAME at name.name#name.org\n\nThank you,\n\nNAME\nAssistant Principal";//modified this
var emailSent = row[13];
if (emailSent != EMAIL_SENT) {
var subject = "Uniform Violation - Do Not Reply";
MailApp.sendEmail(emailAddress, subject, message);
sheet.getRange(startRow + i, 14).setValue(EMAIL_SENT);
SpreadsheetApp.flush();
}
}
}
You will probably have to change the dates format.
Date Format

Displaying Date and Time information in script with format from spreadsheet

I'm working on a basic email-sending script in Google Sheets. I want to send email reminders on clicking a button, reminding people of an appointment at a date and time along with the location.
Everything works, except for the date is displayed in a confusing long form format:
The data shown in the date and time cells is:
8/27/2018
10:30 AM
The data being sent in the email is:
Mon Aug 27 2018 15:00:00 GMT+0800 (HKT)
Sun Dec 31 1899 02:30:00 GMT+0800 (HKT)
I only need to show the date and time as written in the sheets. Is there a way to do this?
Another question is that one person might have more than one appointment, can I combine all appointments date/time for each unique email address into one email instead of multiple emails?
Adding code below:
function sendArticleCountEmails() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.setActiveSheet(ss.getSheetByName("SSname"));
var sheet = SpreadsheetApp.getActiveSheet();
var dataRange = sheet.getRange("B2:O2");
var data = dataRange.getValues();
for (i in data) {
var rowData = data[i];
var emailAddress = rowData[0]; //email
var recipient = rowData[1]; //name1
var message2 = rowData[2]; //Name2
var message3 = rowData[3]; //type
var message4 = rowData[4]; //Appt Date
var message5 = rowData[5]; //Appt Time
var message6 = rowData[6]; //Appt type
var message7 = rowData[7]; //Notes
var message8 = rowData[8]; //Facility Name
var message9 = rowData[9]; //Facility Address
var message10 = rowData[10]; //City
var message11 = rowData[11]; //Zip
var message12 = rowData[12]; //Phone
var message13 = rowData[13]; //Service
var message = 'Dear ' + recipient + ',\n\n' + 'This is a friendly reminder of your assignment tomorrow with:' + '\n\n' + message2 + ' at ' + message5 + '.'
+ '\n\n' + 'The assignment is located at ' + message8 + ', ' + message9 + ', ' + message10 + ', ' + message11 + '.' + '\n\n'
+ 'This assignment is noted as a ' + message6 + ' ' + message3 + ' ' + message13 + '. ' + message7 + '\n\n';
var subject = 'Reminder: ' + message4 + ' ' + message5 + ' (' + message2 + ')';
MailApp.sendEmail(emailAddress, subject, message);
}
}
I think the problem is here, using either var or rowData. The row is correct, just it doesn't pull the data in as shown in Sheets.
var message4 = rowData[4]; //Appt Date
var message5 = rowData[5]; //Appt Time
There is no time in the DATE cell (8/27/2018), so I'm guessing it defaults to "15:00:00" and because my data is input by mailparser, I don't have a method to change the format of the data. Rather I hope I can use the data as displayed in Google Sheets and display this into the Gmail.
I appreciate your suggestions in advance, thanks!

Open Layers issue with markers changing coordinates

I have an issue that is driving me crazy. I have an openlayers map project that works fine. I took this concept code and moved it to a project that utilizes .Net and the projection for the markers/icons get messed up.
//set the Icon/Marker that will be used
var iconStyle = new ol.style.Style({
image: new ol.style.Icon(/** #type {olx.style.IconOptions} */({
anchor: [0.5, 46],
anchorXUnits: 'fraction',
anchorYUnits: 'pixels',
opacity: 0.8,
src: '<%=PinMarkerImage%>'
}))
});
var vectorLayer = new ol.layer.Vector({
source: vectorSource,
style: iconStyle
});
//we will zoom the map to fit the locations after we create
//the map
var mapObj = new ol.Map({
layers: [new ol.layer.Tile({ source: new ol.source.OSM() }), vectorLayer],
target: document.getElementById('map-canvas'),
view: new ol.View({
center: ol.proj.fromLonLat([0, 0]),
zoom: 12
})
});
alert(vectorSource.getExtent());
mapObj.getView().fit(vectorSource.getExtent(), { padding: [75, 40, 40, 75], constrainResolution: false });
//I pass in an object one at a time to populate the features
function changeMapOption(oBranch, i) {
// alert('selected');
var long = oBranch.Longitude;
var lat = oBranch.Latitude;
alert(long + ' ' + lat);
//lastCord = ol.proj.transform([coord[0], coord[1]], 'EPSG:4326', 'EPSG:3857');
var iconFeature = new ol.Feature({
geometry: new ol.geom.Point(ol.proj.transform([long, lat], 'EPSG:4326', 'EPSG:3857')), //ol.proj.fromLonLat([long, lat])),
id: oBranch.Id,
title: oBranch.Name,
address: oBranch.Address + ", " + oBranch.City + ", " + oBranch.State + " " + oBranch.ZipCode
});
//alert(iconFeature.getGeometry());
vectorSource.addFeature(iconFeature);
//mapObj.getView().fit(vectorSource.getExtent(), { padding: [75, 40, 40, 75], constrainResolution: false });
//target = mapObj.getTarget();
//This will zoom the map to fit all of the vector Sources in vectorSource
//alert(vectorSource.getExtent());
//mapObj.addOverlay(popup);
//jTarget = typeof target === "string" ? $("#" + target) : $(target);
//element = document.getElementById('popup');
}
I have the alerts set to check the Longitude and Latitude. These are correct. For this test run I have three objects that are populated, the Longitude and Latitudes are as follows:
-112.04883, 40.492104
-95.673328, 29.95752
-95.638558, 29.880014
When I run the code the alert for the vectorSource.getExtent() produces this:
-12473218.699582075,-8426499.834030088,-10646435.576762961,-6361484.120029401
And the markers show up off the lower coast of Chile. The Latitude is wrong, yet the Longitude appears to be correct.
I could certainly use some guidance here. This is driving me crazy.
Thanks for any assistance.
After trying multiple times, I came up with a solution that works. Hopefully this will help someone down the line.
function loadMarker(oBranch, i) {
var sHTML = getMarkerInfoHtml(oBranch);
var long = oBranch.Longitude * 1;
var lat = oBranch.Latitude * 1;
var iconFeature = new ol.Feature({
geometry: new ol.geom.Point(ol.proj.fromLonLat(([long, lat]))),
index: oBranch.Id,
id: oBranch.Id,
title: oBranch.Name,
address: sHTML //oBranch.Address + ", " + oBranch.City + ", " + oBranch.State + " " + oBranch.ZipCode
});
vectorSource.addFeature(iconFeature);
}
The key was these two lines:
var long = oBranch.Longitude * 1;
var lat = oBranch.Latitude * 1;
by adding the * 1 to the line it forces JavaScript to treat the variables properly as numeric. It now places the markers in the correct location.

Resources