How to get Apple App IDs from given bundle ID? - ios

I have a list of Apple app bundleIds (e.g. com.facebook.Facebook). What I am ultimately trying to achieve is to enrich this data with iTunes metadata, which is available via the iTunes Search API: http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html
I can get the specific information for a specific app if I know the app id (technically, the "trackId"), like so:
http://itunes.apple.com/lookup?id=284882215 (284882215 being the trackId for the Facebook app)
However, I cannot use the bundleId in the same way. How can I systematically retrieve the app id (aka trackId) given the bundleId?

This should work:
curl https://itunes.apple.com/lookup\?bundleId\=com.facebook.Facebook
In the results you should see things like:
"trackViewUrl": "https:\/\/itunes.apple.com\/us\/app\/facebook\/id284882215?mt=8&uo=4",
"bundleId": "com.facebook.Facebook",
"trackId": 284882215,

Based on David Richardson's answer, here's my slightly modified version that uses jq to parse the JSON and extract just the App ID:
$ myApp=WireGuard
$ bID=$(mdls -name kMDItemCFBundleIdentifier -r "/Applications/${myApp}.app")
$ curl -s "https://itunes.apple.com/lookup?bundleId=${bID}" | jq -r '.results[0].trackId'
1451685025

Related

Export dashboard URL from job

I have a notebook running as a job in Azure Databricks. The results are shown in a Databricks dashboard. I want the dashboard URL to be sent to the team when the run is finished.
How do I retrieve the URL of the dashboard for the current run ?
I know the job ID, I managed to get the base of the URL with
dbutils.notebook.entry_point.getDbutils().notebook().getContext().browserHostName().toString()
and I found one can get the Run ID with
dbutils.notebook.entry_point.getDbutils().notebook().getContext().currentRunId().toString()
but the URL should contain the "Run", which is different than the "Run ID". Furthermore, the URL doesn’t display a dashboard without some UUID I don’t know how to get. Where can I get these informations ?
Here is my solution :
run_id = None
url = None
try:
run_id = json.loads(dbutils.notebook.entry_point.getDbutils().notebook().getContext().toJson())["tags"]["idInJob"]
url = f"https://XXX.azuredatabricks.net/?o=YYY#job/11/run/{run_id}/dashboard/ZZZ"
except:
pass
I figured XXX, YYY and ZZZ do not change along runs, you will find them by looking at your sample dashboard.
run_id and url will stay None if the notebook is launched in interactive mode.

How to get the iOS app Apple ID from a Bundle ID?

If I have the Bundle ID of an app, is it possible to programmatically get the Apple ID? eg. the xxx part in this url: http://itunes.apple.com/lookup?id=xxx
Using the lookup url above, it is possible to do the reverse: get the bundle id given an app's apple id.
I'm ultimately looking to programmatically get the icon of an app, but I only know the Bundle ID of the apps. any help is appreciated.
This is actually remarkably easy and can be done programatically by simply changing the parameter of my original query from 'id' to 'bundleID'
eg. http://itunes.apple.com/lookup?bundleId=xxx
The response will be a JSON object with the results that will include the thumbnail url among other things. eg.
{
"resultCount":1,
"results": [
{
"screenshotUrls":[...],
"ipadScreenshotUrls":[...],
"artworkUrl512":"...",
"artistViewUrl":"...",
"artworkUrl60":"...",
"artworkUrl100":"...",
...
}
]
}

A too long link life for S3 object Boto3

After i've generated link on s3 object with boto3, it is living to long...
Too many then it's writen.
url = client.generate_presigned_url(
ClientMethod='get_object',
Params={
'Bucket': bucket_id,
'Key': key
},
ExpiresIn=linc_exp_time
)
What i'm doing wrong?
Your browser might be caching the results. You can test it in a different browser, or by using wget or curl to download rather than using a browser. -- John Rotenstein

How to get youtube channel id using channel custom name?

My question is very similar to this one,
I want to get channel id using channel custom name.
The answer on the question mentioned above which is:
GET https://www.googleapis.com/youtube/v3/search?part=id%2Csnippet&q=annacavalli&type=channel&key={YOUR_API_KEY}
doesn't work on small channels, for ex. when I run it with this channel: https://www.youtube.com/AnnaShearerfashionfettish it returns nothing.
It's very easy, using curl and grep.
Command
channel_name='DOVASYNDROMEYouTubeOfficial' #change this as you like
curl --silent "https://www.youtube.com/c/${channel_name}/videos" |\
grep -o -P '(?<=canonical" href="https://www.youtube.com/channel/)[^"]*'
Output
UCq15_9MvmxT1r2-LLjtkokg
I didn't find a direct way to do this. I did a GET request to get the channel page HTML and parse it.
I used Jsoup to parse the html response.
val doc = Jsoup.parseBodyFragment(body)
val links = doc.select("link[rel=canonical]")
val channelUrl = links.first().attributes().get("href")
Did you try
https://www.googleapis.com/youtube/v3/channels?part=snippetforUsername={username}&key={your key}
Remember to change {your key} to your API key, and {username} to the desired username.

Can I use the Slack API to set the profile picture?

I am running a Slack team for a gaming community. My users all have avatars in the game and I am already using the Slack API to automatically set their Slack user name to their in-game name, so its easier for people to be recognized.
In addition I would also like to automatically set their profile picture in Slack with their avatar picture from the game. However I could not figure out a way to do it, so my question is can it be done and if yes, how?
My current starting point is the undocumented API method users.profile.set which allows me to set the profile of a user (see below for an example of a user profile). So far I've been able to modify:
first_name
last_name
title
phone
skype
The user profile also contains the URL to the profile picture, but I was so far not able to change it. I tried external URLs, and URLs of images already uploaded on Slack.
Here is a link to my documentation of the "undocumented" Slack API method users.profile.set with all options that I could figure out so far.
Any help would be hugely appreciated.
Update November 2017
In the meantime Slack has added a new API method called users.setPhoto for setting profile photos. However, this new method does not solve this question, because it only works for your own user (or more precisely the user you have an access token for, e.g. you not specify another user ID).
I am looking for a way to change the profile pictures of all users on my Slack team by a Slack app / bot.
Example of a user profile:
{
id: "U12345678",
team_id: "T12345678",
name: "erik.kalkoken",
deleted: false,
status: null,
color: "9f69e7",
real_name: "Erik Kalkoken",
tz: "America/Chicago",
tz_label: "Central Daylight Time",
tz_offset: 3600,
profile: {
avatar_hash: "XXX",
first_name: "Erik",
last_name: "Kalkoken",
title: "",
phone: "",
skype: "",
image_24: "https://avatars.slack-edge.com/2016-03-19/XXX_24.jpg",
image_32: "https://avatars.slack-edge.com/2016-03-19/XXX_32.jpg",
image_48: "https://avatars.slack-edge.com/2016-03-19/XXX_48.jpg",
image_72: "https://avatars.slack-edge.com/2016-03-19/XXX_72.jpg",
image_192: "https://avatars.slack-edge.com/2016-03-19/XXX_192.jpg",
image_512: "https://avatars.slack-edge.com/2016-03-19/XXX_512.jpg",
image_1024: "https://avatars.slack-edge.com/2016-03-19/XXX_512.jpg",
image_original: "https://avatars.slack-edge.com/2016-03-19/XXX_original.jpg",
real_name: "Erik Kalkoken",
real_name_normalized: "Erik Kalkoken",
email: "test#email.com"
},
is_admin: false,
is_owner: false,
is_primary_owner: false,
is_restricted: false,
is_ultra_restricted: false,
is_bot: false,
has_2fa: false
}
After messing around with it for a little, it's possible to use the undocumented users.setPhoto endpoint:
curl https://slack.com/api/users.setPhoto \
-F "token=<removed>" \
-F "image=#/path/to/image.jpg"
Unfortunately it will resize your avatar which removes the ability to upload animated gifs.
I don't think the profile picture API is available yet. I read a while back that it was on their TODO list.
I was able to get it to work using Jay Querie's method.
The two difference was I gave the full path and I put the image first.
So in my case:
curl https://slack.com/api/users.setPhoto -F "image=#C:\Users\name\Pictures\dojocat.jpg" -F "token=xxxx-123-123-123-123"
Originally when I was using gitbash to run the curl and it was searching for the image in the directory where my gitbash was installed / being executed. So if I put the dojocat.jpg next to my gitbash executable it would would have found it.

Resources