Accepts
App Store Apps, Articles, Contacts, Dates, Email Addresses, Files, Images, iTunes Products, Locations, Map Links, Media, PDFs, Phone Numbers, Rich Text, Safari Web Pages, Text and URLs
COMMENT
YouTube PIP & Downloader
By Robric18
Version 1.52
COMMENT
What’s new in version 1.52
- fixed broken title retrieval
What’s new in version 1.51
- added dual pip options for if one fails
- changed method for opening YouTube in Safari if can’t open video directly. (Using method provided by u/nyuszika7h)
What’s new in version 1.4
- Bug fixes
- Fixed check for update issue - thanks to @dastefster on RoutineHub for making me aware of the issue
What’s new in versions 1.2 & 1.3
- fixed download issues for certain files
What’s new in version 1.1?
- Added quick PIP setting
- Fixed check for update settings so they actually work
- Added PIP support for cyphered videos (now opens these video in safari)
What’s new in version 1.0?
- Rewritten from the bottom up
- Now supports the YouTube app
DICTIONARY

Dictionary
VARIABLES
Set variable
CFU
to
Check for Updates
DICTIONARY

Dictionary
VARIABLES
Set variable
Quick PIP
to
Quick PIP
DICTIONARY

Dictionary
SCRIPTING
If
CFU
is
Yes
NETWORK
Get contents of
https://routinehub.co/api/v1/shortcuts/
RHID
/versions/latest
Options Under Construction

Contents of URL
SCRIPTING
Get
Value
for
Version
in
Contents of URL

Dictionary Value
SCRIPTING
If
Dictionary Value
is greater than
Version
LIST

List
TEXT
An update is available for
Name
!
What's New in Version
Contents of URL
?
Contents of URL

Text
SCRIPTING
Choose from
List
Prompt
[{'class': 'magic', 'value': 'Text', 'glyph': '', 'UUID': '017695A6-7C63-42DB-B2E5-D5C3BC6C16E9'}]

Chosen Item
SCRIPTING
If
Chosen Item
contains
version
URL
routinehub.co/download/
Contents of URL

URL
NETWORK
Get contents of
URL
Options Under Construction

Contents of URL
DOCUMENTS
Replace
https://www.icloud.com
with
Shortcuts:/
in
Contents of URL

Updated Text
SAFARI
Open
Updated Text
MISSING
output Under Construction
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
SCRIPTING
If
Shortcut Input
does not have any value
SHARING
Get clipboard

Clipboard
SCRIPTING
Otherwise
TEXT
Shortcut Input

Text
SCRIPTING
End If

If Result
VARIABLES
Set variable
Url
to
If Result
TEXT
Match
\byoutube|\byoutu\.be(?!$)|(?<=v\=).{11}|(?<=youtu\.be\/).{11}|(?<=embed\/).{11}
in
Url

Matches
SCRIPTING
Get
Last Item
from
Matches

Item from List
NETWORK
Get contents of
https://noembed.com/embed?url=
Url
Options Under Construction

Contents of URL
SCRIPTING
Get
Value
for
title
in
Contents of URL

Dictionary Value
VARIABLES
Set variable
Video Title
to
Dictionary Value
URL
https://www.youtube.com/get_video_info?video_id=
Item from List

URL
NETWORK
Get contents of
URL
Options Under Construction

Contents of URL
SCRIPTING
Get dictionary from
Contents of URL

Dictionary
SCRIPTING
Get
Value
for
player_response
in
Streaming Data

Dictionary Value
SCRIPTING
Get
Value
for
streamingData
in
Dictionary Value

Dictionary Value
SCRIPTING
If
Dictionary Value
has any value
SCRIPTING
Get
Value
for
streamingData.formats
in
Dictionary Value

Dictionary Value
SCRIPTING
Get
Last Item
from
Dictionary Value

Item from List
SCRIPTING
Get
Value
for
url
in
Item from List

Dictionary Value
VARIABLES
Set variable
PIP Url
to
Dictionary Value
SCRIPTING
End If

If Result
SCRIPTING
If
Shortcut Input
contains
http
COMMENT
Open in Safari from YouTube app if no link
SCRIPTING
If
PIP Url
does not have any value
DOCUMENTS
Replace
www
with
m
in
Shortcut Input

Updated Text
URL
data:text/html,<meta http-equiv="Refresh" content="0; url=
Updated Text
" />

URL
SCRIPTING
Show alert
This video must be opened in Safari for PIP and Downloading
Title
This video must be opened in Safari for PIP and Downloading
SHARING
SAFARI
Open
URL
SCRIPTING
Exit shortcut with
Result
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
SCRIPTING
If
PIP Url
does not have any value
SAFARI
Run JavaScript on
Shortcut Input
Options Under Construction

JavaScript Result
TEXT
JavaScript Result

Text
TEXT
Split
Text
by
New Lines

Split Text
FILES

Files
TEXT
Combine
Files
with
New Lines

Combined Text
DOCUMENTS
Replace
(.*)(\r?\n\1)+
with
$1
in
Combined Text

Updated Text
VARIABLES
Set variable
PIP Url
to
Updated Text
SCRIPTING
End If

If Result
SCRIPTING
If
Quick PIP
is
Yes
TEXT
PIP

Text
SCRIPTING
Otherwise
LIST

List
SCRIPTING
Choose from
List
Prompt
[{'value': 'What do you want to do with the video: ', 'class': 'text'}, {'class': 'magic', 'value': 'Video Title', 'glyph': 'assets/cat/Variable.svg', 'UUID': ''}, {'value': '?', 'class': 'text'}]

Chosen Item
SCRIPTING
End If

If Result
VARIABLES
Set variable
Choice
to
If Result
SCRIPTING
If
Choice
contains
PIP
SCRIPTING
Get the
Device Model

Device Name
SCRIPTING
If
Device Model
is
iPad
NOTIFICATIONS
Show notification
Input
Options Under Construction
SCRIPTING
Otherwise
SAFARI
Open
PIP Url
NOTIFICATIONS
Show notification
Input
Options Under Construction
SCRIPTING
End If

If Result
SCRIPTING
Exit shortcut with
Result
SCRIPTING
Otherwise
NOTIFICATIONS
Show notification
Chosen Item
Options Under Construction
NETWORK
Get contents of
PIP Url
Options Under Construction

Contents of URL
SCRIPTING
Set name of
Contents of URL
to
Contents of URL
.
Video Title

Renamed Item
VARIABLES
Set variable
Downloaded Video
to
Renamed Item
SCRIPTING
If
Chosen Item
contains
Audio
MEDIA
Encode
Downloaded Video
Options Under Construction

Encoded Media
VARIABLES
Set variable
Downloaded Video
to
Encoded Media
TEXT
and converted to an audio file

Text
VARIABLES
Set variable
Audio
to
Text
SCRIPTING
End If

If Result
LIST

List
SCRIPTING
Choose from
List
Prompt
[{'class': 'magic', 'value': 'Audio', 'glyph': 'assets/cat/Variable.svg', 'UUID': ''}, {'value': ' Downloaded', 'class': 'text'}, {'class': 'magic', 'value': 'Video Title', 'glyph': 'assets/cat/Variable.svg', 'UUID': ''}, {'value': '. Do you want to preview it before saving?', 'class': 'text'}]

Chosen Item
SCRIPTING
If
Chosen Item
is
Yes
DOCUMENTS
Show
Downloaded Video
in Quick Look
SCRIPTING
End If

If Result
LIST

List
SCRIPTING
Choose from
List
Prompt
[{'value': 'What do you want to do with ', 'class': 'text'}, {'class': 'magic', 'value': 'Video Title', 'glyph': 'assets/cat/Variable.svg', 'UUID': ''}, {'value': '?', 'class': 'text'}]

Chosen Item
VARIABLES
Set variable
Save choice
to
Chosen Item