I am using dropbox api to lest files in public folder with endpoint https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder
https://api.dropboxapi.com/2/files/list_folder
Response is something like this:
{
"entries": [
{
".tag": "file",
"name": "01.mp4",
"path_lower": "/video/01.mp4",
"path_display": "/video/01.mp4",
"parent_shared_folder_id": "3022865105",
"id": "id:FDeU6KOzmRUAAAAAAAAABw",
"client_modified": "2022-09-14T15:54:42Z",
"server_modified": "2022-09-14T16:06:36Z",
"rev": "5e8a55037c991b42d42d1",
"size": 12347528,
"sharing_info": {
"read_only": false,
"parent_shared_folder_id": "3022865105",
"modified_by": "dbid:AACtZetM6hKYpGsPZvtNDZUFRldH8r35OSk"
},
"is_downloadable": true,
"content_hash": "7e6d5e0d1947523808762a6fc34fec7651393ef9d4f4ea2a64fb71acaf3a1240"
},
{
".tag": "file",
"name": "02.mp4",
"path_lower": "/video/02.mp4",
"path_display": "/video/02.mp4",
"parent_shared_folder_id": "3022865105",
"id": "id:FDeU6KOzmRUAAAAAAAAACA",
"client_modified": "2022-09-14T15:54:42Z",
"server_modified": "2022-09-14T16:06:36Z",
"rev": "5e8a55037c992b42d42d1",
"size": 18791452,
"sharing_info": {
"read_only": false,
"parent_shared_folder_id": "3022865105",
"modified_by": "dbid:AACtZetM6hKYpGsPZvtNDZUFRldH8r35OSk"
},
"is_downloadable": true,
"content_hash": "93d33bf10fa4e5c340dac84ebafb54d0b2759cc6e801da8ab03ae14783365fac"
}
],
"cursor": "AAGUGbHG7ju_3pegzOTPruYbexWxEXYyJGNt5Rt1Frj8QAj_JFDTwppfDTneAq-pMfGEbX4i-aDRndn8j-MrAiLy4mCUDc8-GU_XsUdAoShGXtzWKDsDaQwWCHFmhOo0bBuXElarr3Rdil9pTMqkMcfG2hSZPeepDL_omI0Oo0a-_suATq_zoBrH-o2zNKe9-udR2UrsgPuMl9toei-Tt19FCLHX4uzyT6xAXJjFKnWdfj7y3lgyoxrJqtQPVBc1WT0",
"has_more": false
}
My question is how do I get a direct url link to each file in such a way that I can use it in (let's say) an html5 video tag?
When I right click on a file inside a dropbox folder, the url is something like this:
https://www.dropbox.com/s/305pjdhly2w948y/01.mp4?dl=0
How do I get a direct url like this from this response?
The Dropbox API doesn't offer a way to get such links in bulk. You'll need to make a call to make a link for each file.
To get temporary direct link for a file, you would call /2/files/get_temporary_link:
https://www.dropbox.com/developers/documentation/http/documentation#files-get_temporary_link
The Dropbox API doesn't offer a non-temporary version of that exactly, but you can create a shared link via /2/sharing/create_shared_link_with_settings:
https://www.dropbox.com/developers/documentation/http/documentation#sharing-create_shared_link_with_settings
Or to retrieve existing shared links, use /2/sharing/list_shared_links:
https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_shared_links
That's the same kind of link as returned by the Dropbox web site.
Note that these shared links don't link directly to the file data though. They link to the HTML preview page for the file. You can modify them for direct or raw file access instead though as documented here:
https://help.dropbox.com/share/force-download
Related
I'm programmatically creating Postman collections and want to provide a default JSON request body to make requests easier.
I've looked through the spec can can't see how to specify it. Does anyone have any ideas? Could this be done with JavaScript, which I've used to automatically set headers and environment variables.
Here's the Postman Collection spec definition I'm working with, v2.1.0 draft 4:
https://schema.getpostman.com/collection/json/v2.1.0/draft-04/collection.json
https://schema.getpostman.com/
A request is specified by #/definitions/request.
The body is specified as one of the following. JSON isn't listed so raw is typically used. Here's an excerpt which appears shows that raw is a string type but there's no property to include a default value for the request body.
{
"body":{
"oneOf":[
{
"type":"object",
"description":"This field contains the data usually contained in the request body.",
"properties":{
"mode":{
"description":"Postman stores the type of data associated with this request in this field.",
"enum":[
"raw",
"urlencoded",
"formdata",
"file",
"graphql"
]
},
"raw":{
"type":"string"
}
}
}
]
}
}
Is anyone aware of Postman being able to specify an example for the JSON request body with a pre-created example, using the collection directly or via JavaScript?
UPDATE
The following YouTube video shows on the body can be set dynamically with JavaScript using the following.
const body = {
"productId": 1234
};
pm.globals.set("body", JSON.Stringify(body));
https://www.youtube.com/watch?v=hSX7Dcjy000
Using this approach, it seems the next thing to figure out is if the Postman Collection can import and access custom properties, e.g. x-properties, or if there's some other way to load the example content by overloading an existing property. It seems this can be done by loading a lot of environment variables, one for each request. The final step may be to be to automatically load the correct environment variable value into the example body when the user first brings up the endpoint.
Here's more information on a similar topic:
https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#scripting-with-request-data
The link you added is scripting withing postman test and pre request section , not for programmatically creating json.
You can open postman and click the inverted hamburger menu of collection to export the collection json. You can use this as reference.
In the generated json request is defined as : (Only url , method and body part not full )
"method": "DELETE",
"header": [],
"body": {
"mode": "raw",
"raw": "{{requestbody}}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{url}}/resource1/resource2",
"host": [
"{{url}}"
],
"path": [
"resource1",
"resource2"
]
}
This is the json created from postman.
I'm using Google's Apps Script for this project. I'm using the YouTube data API V3 and of that API I am using the PlaylistItems class. I'm trying to insert a video into a playlist and I've pieced together what I can from the documentation that they have given.
YouTube.PlaylistItems.insert({
"part": [
"snippet"
],
"resource": {
"snippet": {
"playlistId": "PL5t3YGq3D2WnrLyuYL9WCgprQ2RUcwl8a",
"position": 0,
"resourceId": {
"kind": "youtube#video",
"videoId": testVidId
// testVidId is the ID of the video I'm trying to insert
}
}
}
});
When I run this though, I get an error of
Exception: Invalid number of arguments provided. Expected 2-3 only
My question is: what argument am I missing?
I believe your goal as follows.
You want to insert an item to the play list using Google Apps Script.
Modification point:
When YouTube.PlaylistItems.insert(resource, part) is used, the arguments are resource, part which are an object and an array of string, respectively.
When your script is modified, it becomes as follows.
Modified script:
YouTube.PlaylistItems.insert(
{
"snippet": {
"playlistId": "PL5t3YGq3D2WnrLyuYL9WCgprQ2RUcwl8a",
"position": 0,
"resourceId": {
"kind": "youtube#video",
"videoId": testVidId
}
}
},
["snippet"]
);
Note:
Before you use this, please confirm whether YouTube Data API v3 is enabled at Advanced Google services, again.
Reference:
PlaylistItems: insert
I'm trying to figure out if a YouTube video is embeddable using the YouTube Data API v3, from answers to similar questions I noticed the status.embeddable property of videos, for a request like this:
https://www.googleapis.com/youtube/v3/videos?id=63flkf3S1bE&part=contentDetails,status&key={MY_API_KEY}
The response is the following
{
"kind": "youtube#videoListResponse",
"etag": "\"ksCrgYQhtFrXgbHAhi9Fo5t0C2I/ctZQYtBcOuMdnQXh8-Fv1EbS_VA\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"ksCrgYQhtFrXgbHAhi9Fo5t0C2I/Cd8aGZD09NPuGYNumIEozZs2S90\"",
"id": "63flkf3S1bE",
"contentDetails": {
"duration": "PT8M23S",
"dimension": "2d",
"definition": "hd",
"caption": "false",
"licensedContent": false,
"projection": "rectangular"
},
"status": {
"uploadStatus": "processed",
"privacyStatus": "public",
"license": "youtube",
"embeddable": true,
"publicStatsViewable": true,
"madeForKids": false
}
}
]
}
The embeddable parameter under status is returned as true, HOWEVER this video is not actually embeddable, as can be seen here.
When actually embedding the video using the iframe API, there is a more detailed error message as well:
Video unavailable
This video contains content from International Olympic Committee, who has blocked it from display on this website or application.
Watch on YouTube
I don't see how it is possible to detect this case from the YouTube Data API - can anyone help out?
Other option is used in this answer:
Here, you can use the following URL:
https://www.youtube.com/get_video_info?video_id=<VIDEO_ID>
Where VIDEO_ID is the YouTube video_id you want retrieve the information.
In this case, once you get the response, you'll see a property called "playabilityStatus.status".
Here is a extract of the response:
"playabilityStatus": {
"status": "UNPLAYABLE",
"reason": "The video is not available",
"errorScreen": {
"playerErrorMessageRenderer": {
"reason": {
"simpleText": "The video is not available"
},
Additional to johnh10's answer, some of the results saw in the YouTube webpage is not always shown/available in the APIs.
I have the answer. The file that outputs from the https://www.youtube.com/get_video_info?video_id=
is nothing more than a standard text file that is URLENCODED.
To see it properly you first have to DECODE it using a URLDECODER and then you have to separate the json part from the URL querystring part. To take a look at the JSON part you can use a json formatted and to look at the URL part you can use PrettyPrint URL.
Once you do this you will notice that the tag you are looking for to validate weather the video is playable or not is the one mentioned by the other user here. It sits on the URL parameter named "player_response", after you DECODE the file you will find it easily. This parameter holds a longer JSON file that has the playability status under playabilityStatus.Status.
To manipulate it on Javascript simply parse this part of the file as a JSON file and access your node of choice, or parse it as a text and search for the playabilityStatus node that must be unencoded if you dont care to decode it (nothing to fear, only some %2D and %7B instead of spaces and curly brackets).
Good luck!
Unfortunately, this 'copyright check' happens directly from the player. This data is not available through the API.
I'm trying to send in an AIFF base64 through the Google Speech-to-text framework however it seems to only work with WAV files.
The API tells me that I need to set the AudioEncoding to be of a specific type, but I'm not sure which would work with AIFF. I'd also need to set the sampleHertzRate which I'm not sure how to retrieve using Javascript. Can anyone help with this?
Here is my POST body:
{
"config": {
"encoding": "LINEAR16",
"audioChannelCount": 1,
"sampleRateHertz": 8000,
"languageCode": "en-US",
"profanityFilter": "true",
"speechContexts": [],
"enableAutomaticPunctuation": true,
"metadata": {
"interactionType": "VOICE_COMMAND",
"microphoneDistance": "NEARFIELD",
"originalMediaType": "AUDIO",
"recordingDeviceType": "SMARTPHONE",
"recordingDeviceName": "iPhone"
},
"model": "command_and_search"
},
"audio": {
"content": "$base64Audio"
}
}
The API tells me that I need to set the AudioEncoding to be of a
specific type
maybe you have a "data URI problem" mdn MIME_types and you need to attach the data: MIME type to your file? like this:
let base64AudioUrl = `data:audio/x-aiff; base64,${$base64Audio}`;
On wikipedia they define two MIME types for AIFF:
"audio/x-aiff" and "audio/aiff"
If you post your data from a form may be you need to add enctype :
<form method="post" enctype="multipart/form-data">
I'm trying to fetch document objects from Alfresco Community edition,I need the documents path, while i use
SELECT * FROM cmis:document where ''
but i thing the cmis:document namespace doesn't return the path, i was wondering if there is a way to include the path.
PS : i can only use JAVASCRIPT with cmis queries
Instead of a CMIS query you should just fetch the object by URL using its object ID, then grab the path. The browser binding, which is easily invocable from JavaScript, supports this.
For example, suppose I have a file named "test-1.txt" sitting in a folder called "/test" with an Alfresco object ID of:
workspace://SpacesStore/1fb2d9cf-11ca-47c2-94b4-cf72de8f9b92
I can use this URL:
http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root?objectId=workspace://SpacesStore/1fb2d9cf-11ca-47c2-94b4-cf72de8f9b92&cmisselector=parents&includerelativepathsegment=true
To return JSON that includes:
{
"id": "cmis:path",
"localName": "path",
"displayName": "Path",
"queryName": "cmis:path",
"type": "string",
"cardinality": "single",
"value": "\/test"
}
Which contains the path.
You can shorten up the JSON significantly by also adding "&succinct=true"
Another option would be to write your own Javascript backed web script. It's controller would find the node using CMIS query, and it's FTL would actually display the path in any format you like.
https://community.alfresco.com/docs/DOC-6243-50-javascript-api
http://docs.alfresco.com/5.0/references/API-JS-ScriptNode.html