Example #1
0
LookupType GuessLookupType(const QString &inetref)
{
    if (inetref.isEmpty() || inetref == "00000000" ||
        inetref == MetaGrabberScript::CleanedInetref(inetref))
    {
        // can't determine subtype from inetref
        return kUnknownVideo;
    }

    // inetref is defined, see if we have a pre-defined grabber
    MetaGrabberScript grabber =
        MetaGrabberScript::FromInetref(inetref);

    if (!grabber.IsValid())
    {
        return kUnknownVideo;
    }

    switch (grabber.GetType())
    {
        case kGrabberMovie:
            return kProbableMovie;
        case kGrabberTelevision:
            return kProbableTelevision;
        default:
            return kUnknownVideo;
    }
}
Example #2
0
MetaGrabberScript MetaGrabberScript::FromInetref(const QString &inetref,
                                                 bool absolute)
{
    static QRegExp retagref("^([a-zA-Z0-9_\\-\\.]+\\.[a-zA-Z0-9]{1,3})_(.*)");
    static QRegExp retagref2("^([a-zA-Z0-9_\\-\\.]+\\.[a-zA-Z0-9]{1,3}):(.*)");
    static QMutex reLock;
    QMutexLocker lock(&reLock);
    QString tag;

    if (retagref.indexIn(inetref) > -1)
    {
        tag = retagref.cap(1);
    }
    else if (retagref2.indexIn(inetref) > -1)
    {
        tag = retagref2.cap(1);
    }
    if (!tag.isEmpty())
    {
        // match found, pull out the grabber
        MetaGrabberScript script = MetaGrabberScript::FromTag(tag, absolute);
        if (script.IsValid())
            return script;
    }

    // no working match, return a blank
    return MetaGrabberScript();
}
Example #3
0
MetaGrabberScript MetaGrabberScript::GetGrabber(GrabberType defaultType,
                                                const MetadataLookup *lookup)
{
    if (!lookup)
    {
        return GetType(defaultType);
    }

    if (!lookup->GetInetref().isEmpty() &&
        lookup->GetInetref() != "00000000")
    {
        // inetref is defined, see if we have a pre-defined grabber
        MetaGrabberScript grabber = FromInetref(lookup->GetInetref());

        if (grabber.IsValid())
        {
            return grabber;
        }
        // matching grabber was not found, just use the default
        // fall through
    }

    return GetType(defaultType);
}
Example #4
0
void GrabberSettings::Load(void)
{
    QDir TVScriptPath = QString("%1metadata/Television/").arg(GetShareDir());
    QStringList TVScripts = TVScriptPath.entryList(QDir::Files);
    QDir MovieScriptPath = QString("%1metadata/Movie/").arg(GetShareDir());
    QStringList MovieScripts = MovieScriptPath.entryList(QDir::Files);
    QDir GameScriptPath = QString("%1metadata/Game/").arg(GetShareDir());
    QStringList GameScripts = GameScriptPath.entryList(QDir::Files);

    if (MovieScripts.count())
    {
        for (QStringList::const_iterator i = MovieScripts.begin();
             i != MovieScripts.end(); ++i)
        {
            QString commandline = QString("%1/%2")
                                      .arg(MovieScriptPath.path()).arg(*i);
            MythSystemLegacy grabber(commandline, QStringList() << "-v", kMSRunShell | kMSStdOut);
            grabber.Run();
            grabber.Wait();
            QByteArray result = grabber.ReadAll();

            if (!result.isEmpty())
            {
                QDomDocument doc;
                doc.setContent(result, true);
                QDomElement root = doc.documentElement();
                if (!root.isNull())
                {
                    MetaGrabberScript *script = ParseGrabberVersion(root);
                    if (!script->GetName().isEmpty())
                        m_movieGrabberList.append(script);
                }
            }
        }
    }

    if (TVScripts.count())
    {
        for (QStringList::const_iterator i = TVScripts.end() - 1;
                i != TVScripts.begin() - 1; --i)
        {
            QString commandline = QString("%1/%2")
                                      .arg(TVScriptPath.path()).arg(*i);
            MythSystemLegacy grabber(commandline, QStringList() << "-v", kMSRunShell | kMSStdOut);
            grabber.Run();
            grabber.Wait();
            QByteArray result = grabber.ReadAll();

            if (!result.isEmpty())
            {
                QDomDocument doc;
                doc.setContent(result, true);
                QDomElement root = doc.documentElement();
                if (!root.isNull())
                {
                    MetaGrabberScript *script = ParseGrabberVersion(root);
                    if (!script->GetName().isEmpty())
                        m_tvGrabberList.append(script);

                }
            }
        }
    }

    if (GameScripts.count())
    {
        for (QStringList::const_iterator i = GameScripts.end() - 1;
                i != GameScripts.begin() - 1; --i)
        {
            QString commandline = QString("%1/%2")
                                      .arg(GameScriptPath.path()).arg(*i);
            MythSystemLegacy grabber(commandline, QStringList() << "-v", kMSRunShell | kMSStdOut);
            grabber.Run();
            grabber.Wait();
            QByteArray result = grabber.ReadAll();

            if (!result.isEmpty())
            {
                QDomDocument doc;
                doc.setContent(result, true);
                QDomElement root = doc.documentElement();
                if (!root.isNull())
                {
                    MetaGrabberScript *script = ParseGrabberVersion(root);
                    if (!script->GetName().isEmpty())
                        m_gameGrabberList.append(script);
                }
            }
        }
    }
}
Example #5
0
void GrabberSettings::Load(void)
{
    QString busymessage = tr("Searching for data sources...");
    MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
    MythUIBusyDialog *busyPopup = new MythUIBusyDialog(busymessage, popupStack,
                                                       "grabberbusydialog");

    if (busyPopup->Create())
    {
        popupStack->AddScreen(busyPopup, false);
    }
    else
    {
        delete busyPopup;
        busyPopup = NULL;
    }

    QDir TVScriptPath = QString("%1metadata/Television/").arg(GetShareDir());
    QStringList TVScripts = TVScriptPath.entryList(QDir::Files);
    QDir MovieScriptPath = QString("%1metadata/Movie/").arg(GetShareDir());
    QStringList MovieScripts = MovieScriptPath.entryList(QDir::Files);
    QDir GameScriptPath = QString("%1metadata/Game/").arg(GetShareDir());
    QStringList GameScripts = GameScriptPath.entryList(QDir::Files);

    if (MovieScripts.count())
    {
        for (QStringList::const_iterator i = MovieScripts.begin();
                i != MovieScripts.end(); i++)
        {
            QString commandline = QString("%1/%2")
                                      .arg(MovieScriptPath.path()).arg(*i);
            MythSystem grabber(commandline, QStringList() << "-v", kMSRunShell | kMSStdOut | kMSBuffered);
            grabber.Run();
            grabber.Wait();
            QByteArray result = grabber.ReadAll();

            if (!result.isEmpty())
            {
                QDomDocument doc;
                doc.setContent(result, true);
                QDomElement root = doc.documentElement();
                if (!root.isNull())
                {
                    MetaGrabberScript *script = ParseGrabberVersion(root);
                    if (!script->GetName().isEmpty())
                        m_movieGrabberList.append(script);
                }
            }
        }
    }

    if (TVScripts.count())
    {
        for (QStringList::const_iterator i = TVScripts.end() - 1;
                i != TVScripts.begin() - 1; --i)
        {
            QString commandline = QString("%1/%2")
                                      .arg(TVScriptPath.path()).arg(*i);
            MythSystem grabber(commandline, QStringList() << "-v", kMSRunShell | kMSStdOut | kMSBuffered);
            grabber.Run();
            grabber.Wait();
            QByteArray result = grabber.ReadAll();

            if (!result.isEmpty())
            {
                QDomDocument doc;
                doc.setContent(result, true);
                QDomElement root = doc.documentElement();
                if (!root.isNull())
                {
                    MetaGrabberScript *script = ParseGrabberVersion(root);
                    if (!script->GetName().isEmpty())
                        m_tvGrabberList.append(script);

                }
            }
        }
    }

    if (GameScripts.count())
    {
        for (QStringList::const_iterator i = GameScripts.end() - 1;
                i != GameScripts.begin() - 1; --i)
        {
            QString commandline = QString("%1/%2")
                                      .arg(GameScriptPath.path()).arg(*i);
            MythSystem grabber(commandline, QStringList() << "-v", kMSRunShell | kMSStdOut | kMSBuffered);
            grabber.Run();
            grabber.Wait();
            QByteArray result = grabber.ReadAll();

            if (!result.isEmpty())
            {
                QDomDocument doc;
                doc.setContent(result, true);
                QDomElement root = doc.documentElement();
                if (!root.isNull())
                {
                    MetaGrabberScript *script = ParseGrabberVersion(root);
                    if (!script->GetName().isEmpty())
                        m_gameGrabberList.append(script);
                }
            }
        }
    }

    if (busyPopup)
    {
        busyPopup->Close();
        busyPopup = NULL;
    }
}