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);
                }
            }
        }
    }
}
Exemple #2
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;
    }
}