-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
let QMPlay2 handle youtube:XXYYZZ URIs #619
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[Desktop Entry] | ||
Exec=QMPlay2 --show %u | ||
Icon=QMPlay2 | ||
Name=Play youtube:VID URI in QMPlay2 | ||
StartupNotify=false | ||
Type=Application | ||
Categories=Qt;AudioVideo;Player;Audio;Video; | ||
MimeType=x-scheme-handler/youtube; | ||
NoDisplay=true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -641,13 +641,30 @@ QStringList Functions::getUrlsFromMimeData(const QMimeData *mimeData, const bool | |
|
||
QString Functions::maybeExtensionAddress(const QString &url) | ||
{ | ||
for (const QMPlay2Extensions *QMPlay2Ext : QMPlay2Extensions::QMPlay2ExtensionsList()) | ||
if (url.startsWith("youtube:")) | ||
{ | ||
const QString prefix = QMPlay2Ext->matchAddress(url); | ||
if (!prefix.isEmpty()) | ||
return prefix + "://{" + url + "}"; | ||
// we want to support both youtube:vID and youtube://vID but the latter form | ||
// is often passed to us as "youtube://vid" (vID interpreted as the remote host). | ||
// So we also support the full URI form with an empty host string and strip | ||
// the leading '/' from the path to recover the intact vID. This implementation | ||
// also supports youtube:/vID as a side effect ... why not! | ||
auto vid = url.mid(8); | ||
while (vid.at(0) == '/') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Crash if Btw. do we really need the |
||
{ | ||
vid.remove(0, 1); | ||
} | ||
return maybeExtensionAddress("http://www.youtube.com/watch?v=" + vid); | ||
} | ||
else | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
{ | ||
for (const QMPlay2Extensions *QMPlay2Ext : QMPlay2Extensions::QMPlay2ExtensionsList()) | ||
{ | ||
const QString prefix = QMPlay2Ext->matchAddress(url); | ||
if (!prefix.isEmpty()) | ||
return prefix + "://{" + url + "}"; | ||
} | ||
return url; | ||
} | ||
return url; | ||
} | ||
|
||
bool Functions::splitPrefixAndUrlIfHasPluginPrefix(const QString &entireUrl, QString *addressPrefixName, QString *url, QString *param) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add
auto fileOpenEvent = (QFileOpenEvent *)event;
and use it?