Image donot show in rich response in actions on Google - actions-on-google

Images donot show in basic card in rich response
I have provided the url of image but it didn't show an image
#Prisoner here is my code, please let me know if i am doing any mistake
app.intent('totalResponses', (conv, { Location }) => {
// extract the num parameter as a local string variable
if (!conv.surface.capabilities.has('actions.capability.SCREEN_OUTPUT')) {
conv.ask('Sorry, try this on a screen device or select the ' +
'phone surface in the simulator.');
return;
}
conv.ask('Hello World');
conv.ask(new BasicCard({
text: `Hello`, // Note the two spaces before '\n' required for
// a line break to be rendered in the card.
title: 'Title: this is a title',
image: new Image({
url: 'https://drive.google.com/file/d/13eEr2rYhSCEDKDwCLab29AqFMsKuOi4P/view',
alt: 'Image alternate text',
}),
}));
});

The problem is with the drive URL that you're using for the image. This URL is the one that is used to preview the image when you load it from Google Drive directly. It is an HTML page, rather than an image, so it won't display if you use it in a web page or in a card for the assistant.
To get the URL you need to use, you want to select the three dots at the top of that page and then "Embed item". You don't want to use the entire embed code - just the URL.

Follow the below steps for a solution:
Get a shareable link URL from drive.
Open the terminal(UNIX) and execute this command. Can also use online unix based or local terminal
https://www.tutorialspoint.com/execute_bash_online.php
Execute the following code
echo <paste your link> | cut -d '/' -f 6
Copy the output which is a unique id.
Paste it after &id=:
https://drive.google.com/uc?export=view&id=<paste the output unique key>

Related

How to inject/track editor/document meta-data?

Is there a way to inject custom properties into a document/editor?
For example, I need to edit text from an api endpoint. It's easy to make the api call and display the data in an editor, then edit the text. I cannot seem to find a good way to put the meta-data about the text so a post can be made to update the source. Need to hold information like api-end-point and document id without injecting it into the main editor text.
I have been looking into everything from a CustomDocument/provider to a custome file system provider, but those options seem to be rather complicated for what I need.
Example:
api-endpoint: GET /docs
const resp = [{
name: /docs/note1.txt,
id: 12345,
content: 'some text document content'
}, {
name: /notes/othernote.txt
id: 54312,
content: 'special text in another note'
}];
// open a document/editor and display the content of one of the docs from the api reponse
await workspace.openTextDocument({ content: resp[0].content, language: 'text' })
.then( async (doc) => {
await window.showTextDocument( doc, { preview: false });
this.documents.push(doc);
});
Now we have an editor displaying the content but no way to link that content back to the api endpoint (with doc id). It seems I need to be looking the file system provider so I can inject additional details in to the file stats.
https://code.visualstudio.com/api/references/vscode-api#FileSystemProvider
Suggestions?

Add furigana into Website Content

I need to make auto furigana view for my Japanese website content. For that I just tried many possible solutions.
In Yahoo's API there is a way of doing it.
<?php
$appid = 'My api Key';
$sentence1="日本";
$sentence = mb_convert_encoding($sentence1, 'utf-8', 'auto');
echo $request = "http://jlp.yahooapis.jp/FuriganaService/V1/furigana?appid=".$appid."&sentence=".urlencode($sentence);
But In this Yahoo API, we need to include all content into a variable and split into separate. It makes more time because my content is dynamics.
I need a auto furigana solution like IPA Furigana Google Extension.
Thanks in advance.
https://www.furiousgana.com/api/
Adding this here for anyone who might be interested in furigana generation.
You can generate furigana by sending a post request to this 'https://api.furiousgana.com' and setting the body of the data to an object or array.
The English tag is optional.
const query = [
{
japanese:'気を付けて',
english:'Take care!'
},
{
japanese:'お元気ですか?',
english:'Are you ok?'
}
]
axios({
method: 'post',
url: 'https://api.furiousgana.com',
data: query
})
.then(({data})=>{
console.log(data) // here is you data
});
The final step would be to parse the generated furigana so that it wraps the content in & tags
This github will help full for furigana.
Just pass the variable to the kuroshiro.convert('variable') and then you will get the data with furigana also with ruby tag.
https://github.com/hexenq/kuroshiro.js

Access Soundcloud Charts with API

Is there an way to access the new charts https://soundcloud.com/charts/top (top 50) with the soundcloud api? Or is there an other way?
Maybe with an crawl with php or something?
To found parameters that you can use with HTTP API Request, you can do this:
Go to "https://soundcloud.com/charts/" and open Console (F12 on Chrome).
Go inside Network Tab of Console and Refresh page (F5).
Clear Console.
Now for example if you want know parameters for retrive "TOP 50 - Dance & EDM":
Change values inside the filter box
Check in the console, the request that start with: "charts?kind="
Search inside this url the parameters.
Some example:
TOP | Dance & EDM
https ://api-v2.soundcloud.com/charts?kind=top&genre=soundcloud%3Ageneres%3Adanceedm&client_id=...
TOP | Deep House
https ://api-v2.soundcloud.com/charts?kind=top&genre=soundcloud%3Agenres%3Adeephouse&client_id=...
New & Hot
Country
https ://api-v2.soundcloud.com/charts?kind=trending&genre=soundcloud%3Agenres%3Acountry&client_id=...
All Parameters:
kind:
top <- Top 50
trending <- New & Hot
genre:
soundcloud:genres:all-music
soundcloud:genres:all-audio
soundcloud:genres:alternativerock
soundcloud:genres:ambient
soundcloud:genres:classical
soundcloud:genres:country
soundcloud:genres:danceedm
soundcloud:genres:dancehall
soundcloud:genres:deephouse
soundcloud:genres:disco
soundcloud:genres:drumbass
soundcloud:genres:dubstep
soundcloud:genres:electronic
soundcloud:genres:folksingersongwriter
soundcloud:genres:hiphoprap
soundcloud:genres:house
soundcloud:genres:indie
soundcloud:genres:jazzblues
soundcloud:genres:latin
soundcloud:genres:metal
soundcloud:genres:piano
soundcloud:genres:pop
soundcloud:genres:rbsoul
soundcloud:genres:reggae
soundcloud:genres:reggaeton
soundcloud:genres:rock
soundcloud:genres:soundtrack
soundcloud:genres:techno
soundcloud:genres:trance
soundcloud:genres:trap
soundcloud:genres:triphop
soundcloud:genres:world
soundcloud:genres:audiobooks
soundcloud:genres:business
soundcloud:genres:comedy
soundcloud:genres:entertainment
soundcloud:genres:learning
soundcloud:genres:newspolitics
soundcloud:genres:religionspirituality
soundcloud:genres:science
soundcloud:genres:sports
soundcloud:genres:storytelling
soundcloud:genres:technology
Example in php to get a json response of TOP50 - Country:
URL:
https ://api-v2.soundcloud.com/charts?kind=top&genre=soundcloud%3Agenres%3Acountry&client_id=XXXXXXXXXXX&limit=10&linked_partitioning=1
URL Parameters:
Kind: Top
Genre: soundcloud:genres:country
client_id: XXXXXXXXXXX
limit: 10
linked_partitioning: 1
limit: how many songs you want to receive in response.
linked_partitioning: page number, according to the limit.
e.g. linked_partitioning with Limit = 10:
1 get song from 0 to 9
2 get song from 10 to 19
...
e.g. linked_partitioning with Limit = 20:
1 get song from 0 to 19
2 get song from 20 to 39
...
Now that you have URL, if you want retrive JSON response with PHP
you have to write for example:
<?php
$url = "https://api-v2.soundcloud.com/charts?kind=top&genre=soundcloud%3Agenres%3Acountry&client_id=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&limit=10&linked_partitioning=1";
// Get JSON Response
$json = file_get_contents($url);
// Decode response to array
$objectJSON = json_decode($json, true);
Example Json Response:
{
"genre":"soundcloud:genres:country",
"kind":"top",
"last_updated":"2016-03-24T09:50:02Z",
"collection":[
{
"track":{
"commentable":true,
"comment_count":211,
"downloadable":true,
"download_count":80,
"duration":251060,
.
.
.
"kind":"track",
.
.
.
.
"license":"all-rights-reserved",
"streamable":true,
"title":"Award winning Falling Star",
"uri":"https://api.soundcloud.com/tracks/245170733",
.
.
.
"country_code":"US"
}
"score":1093171.0
},
{
...
},
OTHER TRACKS HERE...
],
"query_urn":"soundcloud:charts:bc9b903f2cee44e7bca955bc2fc4601d",
"next_href":"https://api-v2.soundcloud.com/charts?genre=soundcloud%3Agenres%3Acountry&query_urn=soundcloud%3Acharts%3Abc9b903f2cee44e7bca955bc2fc4601d&offset=20&kind=top&limit=20"
}
}
If you want read JSON content of response:
// Read Json taking for example Name, Title and SoundCloud URI of song.
foreach ($objectJSON["collection"] as $key => $value) {
echo 'user: ' . $value['track']['user']['full_name'] . "<br/>";
echo 'title: ' . $value['track']['title'] . "<br/>";
echo 'url: ' . $value['track']['uri'] . "<br/><br/>";
}
echo $response;
?>
Result of this PHP:
user: ...
title: ...
url: ...
user: ...
title: ...
url: ...
...
Example of this code
I hope I have helped you and sorry for my english.
EDIT:
I think that SoundCloud has changed the way to get the next page.
Now you need to change the "offset" param.
Like this:
Page 1: ....&limit=20&offset=0
Page 2: ....&limit=20&offset=20
Page 3: ....&limit=20&offset=40
ANSWER FOR #VietHung QUESTION.
Q: Can you explore system playlists?
(Eg: soundcloud:system-playlists charts-top:all-music)
To find system playlist, I have used Charles Web Debugging Proxy.
The idea is to sniff network package sent by SoundClound App from iOS device (in my case).
After that you configure Charles to sniff SSL packages correctly, you can use you pc as proxy for your smartphone.
(You must install Charles cert on Windows and on iOS device to sniff SSL packages correctly, for more information search on google).
Now, open SoundCloud App and click on every playlists (TOP, NEWS) inside the app.
Below a screenshot (Quality powered by paint, sorry ahah):
Now inside Charles we can see something like this:
I set the focus only on the SoundCloud host for better reading of incoming packages.
Charles is smart and puts all similar requests into a subfolder, in our case we have to look at all the requests within 'system-playlist'.
Now from all requests you can retrieve all system playlists values.
I have not listed all playlist song because currently I do not have much time.
As soon as I can, I edit this post with the complete list of possible system playlists vales.
Here is an example:
https://api-v2.soundcloud.com/charts?kind=top&genre=soundcloud%3Agenres%3Aall-music&client_id=02gUJC0hH2ct1EGOcYXQIzRFU91c72Ea&limit=20&offset=0
Just change the params according to your client id, etc.

Filepicker.io Javascript API Remove

Trying to use the remove function after the pick function and file is not being removed. (from here https://www.filepicker.com/documentation/file_ingestion/javascript_api/remove?v=v2)
selectFileMedium: function () {
filepicker.pick({
cropRatio: 24/13,
mimetype: 'image/*',
imageDim: [1440, 780]
}, function (Blob) {
InnerThis.uploadMediumImage(Blob.url, Blob.filename);
filepicker.remove(Blob);
});
}
Am I doing this correct?
Blob object return url property which is unificated url of uploaded file eg:
https://www.filepicker.io/api/file/AQgF2U68SNmJDpDXlOdg
However since v2 dialog version there is crop UI avaliable. If user crop file as a response it return the uploaded file url with appended Rest convert parameters:
https://www.filepicker.io/api/file/AQgF2U68SNmJDpDXlOdg/convert?crop=100,200,200,300
filepicker.remove dose not deal with it. Some temporary workaround would be to strip url from '/convert' part just before remove it. However it should be solved on library side.

Manage Titles when Uploading Multiple Images

It would be great if we could manage the titles of each image that we upload when uploading multiple images. This way I could select each image that I want to upload, title them, then hit the upload button. Right now one must either upload one by one or have all the selected images have the same title.
Kinda like Facebook or Panoramio where it's easy to manage the titles of the images before uploading.
This isn't natively supported in Fine Uploader at the moment, but I've opened up a feature request and tentatively scheduled it for the 3.7 milestone. In the meantime, you can certainly provide your own UI elements to allow users to provide alternate names for each upload-able item and pass these new names as a parameter. Server-side, you would have to parse this parameter and associate it with the uploaded item. Fine Uploader will have to adopt a parameter name that contains the user-supplied alternate filename anyway (and the server will have to be aware of this convention and parse this parameter), since we won't be able to change the value file input field sent along with the multipart encoded request.
use this:
var uploader = $('.uploader'),
titleBox = $('input[type=text]');
uploader.fineUploader({
request: {
endpoint: 'path/to/url'
},
formatFileName: function (name) {
var title = titleBox.val() + ' - ' + name + '';
titleBox.val('');
return title;
},
});
uploader.on('submit', function (event, id, name) {
uploader.fineUploader('setParams', {title: titleBox.val()}, id);
});