Esempio n. 1
0
void CPPageSubDB::OnBnClickedButton1()
{
	CString ISDb, ver, msg, str;

	m_ISDbCombo.GetWindowText(ISDb);
	ISDb.TrimRight('/');

	ver.Format(_T("ISDb v%d"), ISDb_PROTOCOL_VERSION);

	CWebTextFile wtf;
	if(wtf.Open(_T("http://") + ISDb + _T("/test.php")) && wtf.ReadString(str) && str == ver)
	{
		msg = ResStr(IDS_PPSDB_URLCORRECT);
	}
	else if(str.Find(_T("ISDb v")) == 0)
	{
		msg = ResStr(IDS_PPSDB_PROTOCOLERR);
	}
	else
	{
		msg = ResStr(IDS_PPSDB_BADURL);
	}

	AfxMessageBox(msg, MB_OK);
}
Esempio n. 2
0
void CPPageSubMisc::OnBnClickedTestSubsDB()
{
    CString ISDb, ver, str;
    UINT msg;

    m_ISDbCombo.GetWindowText(ISDb);
    ISDb.TrimRight('/');

    ver.Format(_T("ISDb v%d"), ISDb_PROTOCOL_VERSION);

    CWebTextFile wtf;
    UINT nIconType = MB_ICONEXCLAMATION;

    if (wtf.Open(_T("http://") + ISDb + _T("/test.php")) && wtf.ReadString(str) && str == ver) {
        msg = IDS_PPSDB_URLCORRECT;
        nIconType = MB_ICONINFORMATION;
    } else if (str.Find(_T("ISDb v")) == 0) {
        msg = IDS_PPSDB_PROTOCOLERR;
    } else {
        msg = IDS_PPSDB_BADURL;
    }

    AfxMessageBox(msg, nIconType | MB_OK, 0);
}
Esempio n. 3
0
void GetSubFileNames(CString fn, CAtlArray<CString>& paths, CString load_ext_list, CAtlArray<SubFile>& ret)
{
    XY_LOG_INFO(XY_LOG_VAR_2_STR(fn.GetString())<<XY_LOG_VAR_2_STR(paths.GetCount())<<XY_LOG_VAR_2_STR(load_ext_list.GetString()));

    ret.RemoveAll();

    fn.Replace('\\', '/');

    bool fWeb = false;
    {
        //int i = fn.Find(_T("://"));
        int i = fn.Find(_T("http://"));
        if(i > 0) {fn = _T("http") + fn.Mid(i); fWeb = true;}
    }

    int	l = fn.GetLength(), l2 = l;
    l2 = fn.ReverseFind('.');
    l = fn.ReverseFind('/') + 1;
    if(l2 < l) l2 = l;

    CString orgpath = fn.Left(l);
    CString title = fn.Mid(l, l2-l);
    CString filename = title + _T(".nooneexpectsthespanishinquisition");
    
    ExtSupport ext_support;
    if (!ext_support.init(load_ext_list))
    {
        XY_LOG_INFO(_T("unexpected error"));
        return;
    }

    if(!fWeb)
    {
        WIN32_FIND_DATA wfd;
        for(size_t k = 0; k < paths.GetCount(); k++)
        {
            CString path = paths[k];
            path.Replace('\\', '/');

            l = path.GetLength();
            if(l > 0 && path[l-1] != '/') path += '/';

            if(path.Find(':') == -1 && path.Find(_T("\\\\")) != 0) path = orgpath + path;

            path.Replace(_T("/./"), _T("/"));
            path.Replace('/', '\\');

            CAtlList<CString> sl;

            bool fEmpty = true;

            HANDLE hFile = FindFirstFile(path + title + _T(".*"), &wfd);
            if(hFile != INVALID_HANDLE_VALUE)
            {
                do
                {
                    if(filename.CompareNoCase(wfd.cFileName) != 0) 
                    {
                        fEmpty = false;
                        sl.AddTail(wfd.cFileName);
                    }
                }
                while(FindNextFile(hFile, &wfd));

                FindClose(hFile);
            }

            if(fEmpty) continue;

            POSITION pos = sl.GetHeadPosition();
            while(pos)
            {
                const CString& fn = sl.GetNext(pos);
                int l = fn.ReverseFind('.');
                CString ext = fn.Mid(l+1).MakeLower();
                int ext_order = ext_support.ext_support_order(ext);
                if (ext_order>-1)
                {
                    SubFile f;
                    f.full_file_name = path + fn;

                    int l2 = fn.Find('.');
                    if (l2==l)
                    {
                        f.extra_name = "";
                    }
                    else
                    {
                        f.extra_name = fn.Mid(l2+1, l-l2-1);
                    }

                    f.ext_order = ext_order;
                    f.path_order = k;
                    ret.Add(f);
                }
            }
        }
    }
    else if(l > 7)
    {
        CWebTextFile wtf; // :)
        if(wtf.Open(orgpath + title + WEBSUBEXT))
        {
            CString fn;
            while(wtf.ReadString(fn) && fn.Find(_T("://")) >= 0)
            {
                SubFile f;
                f.full_file_name = fn;
                f.extra_name = fn.Mid(fn.ReverseFind('/')+1);
                f.ext_order = MAXINT32;
                f.path_order = MAXINT32;
                ret.Add(f);
            }
        }
    }

    // sort files, this way the user can define the order (movie.00.English.srt, movie.01.Hungarian.srt, etc)

    qsort(ret.GetData(), ret.GetCount(), sizeof(SubFile), SubFileCompare);
}
Esempio n. 4
0
bool CPlayerPlaylistBar::ParseMPCPlayList(CString fn)
{
    CString str;
    CAtlMap<int, CPlaylistItem> pli;
    CAtlArray<int> idx;

    CWebTextFile f;
    if (!f.Open(fn) || !f.ReadString(str) || str != _T("MPCPLAYLIST")) {
        return false;
    }

    if (f.GetEncoding() == CTextFile::ASCII) {
        f.SetEncoding(CTextFile::ANSI);
    }

    CPath base(fn);
    base.RemoveFileSpec();

    while (f.ReadString(str)) {
        CAtlList<CString> sl;
        Explode(str, sl, ',', 3);
        if (sl.GetCount() != 3) {
            continue;
        }

        if (int i = _ttoi(sl.RemoveHead())) {
            CString key = sl.RemoveHead();
            CString value = sl.RemoveHead();

            if (key == _T("type")) {
                pli[i].m_type = (CPlaylistItem::type_t)_ttol(value);
                idx.Add(i);
            } else if (key == _T("label")) {
                pli[i].m_label = value;
            } else if (key == _T("filename")) {
                value = CombinePath(base, value);
                pli[i].m_fns.AddTail(value);
            } else if (key == _T("subtitle")) {
                value = CombinePath(base, value);
                pli[i].m_subs.AddTail(value);
            } else if (key == _T("video")) {
                while (pli[i].m_fns.GetCount() < 2) {
                    pli[i].m_fns.AddTail(_T(""));
                }
                pli[i].m_fns.GetHead() = value;
            } else if (key == _T("audio")) {
                while (pli[i].m_fns.GetCount() < 2) {
                    pli[i].m_fns.AddTail(_T(""));
                }
                pli[i].m_fns.GetTail() = value;
            } else if (key == _T("vinput")) {
                pli[i].m_vinput = _ttol(value);
            } else if (key == _T("vchannel")) {
                pli[i].m_vchannel = _ttol(value);
            } else if (key == _T("ainput")) {
                pli[i].m_ainput = _ttol(value);
            } else if (key == _T("country")) {
                pli[i].m_country = _ttol(value);
            }
        }
    }

    qsort(idx.GetData(), idx.GetCount(), sizeof(int), s_int_comp);
    for (size_t i = 0; i < idx.GetCount(); i++) {
        m_pl.AddTail(pli[idx[i]]);
    }

    return pli.GetCount() > 0;
}
Esempio n. 5
0
void GetSubFileNames(CString fn, CAtlArray<CString>& paths, CAtlArray<SubFile>& ret)
{
	ret.RemoveAll();

	int extlistnum = _countof(ext);
	int extsubnum = _countof(ext[0]);

	fn.Replace('\\', '/');

	bool fWeb = false;
	{
		//		int i = fn.Find(_T("://"));
		int i = fn.Find(_T("http://"));
		if (i > 0) {
			fn = _T("http") + fn.Mid(i);
			fWeb = true;
		}
	}

	int	l = fn.GetLength(), l2 = l;
	l2 = fn.ReverseFind('.');
	l = fn.ReverseFind('/') + 1;
	if (l2 < l) {
		l2 = l;
	}

	CString orgpath = fn.Left(l);
	CString title = fn.Mid(l, l2-l);
	CString filename = title + _T(".nooneexpectsthespanishinquisition");

	if (!fWeb) {
		// struct _tfinddata_t file, file2;
		// long hFile, hFile2 = 0;

		WIN32_FIND_DATA wfd, wfd2;
		HANDLE hFile, hFile2;

		for (size_t k = 0; k < paths.GetCount(); k++) {
			CString path = paths[k];
			path.Replace('\\', '/');

			l = path.GetLength();
			if (l > 0 && path[l-1] != '/') {
				path += '/';
			}

			if (path.Find(':') == -1 && path.Find(_T("\\\\")) != 0) {
				path = orgpath + path;
			}

			path.Replace(_T("/./"), _T("/"));
			path.Replace('/', '\\');

			// CAtlList<CString> sl;

			bool fEmpty = true;

			if ((hFile = FindFirstFile(path + title + _T("*"), &wfd)) != INVALID_HANDLE_VALUE) {
				do {
					if (filename.CompareNoCase(wfd.cFileName) != 0) {
						fEmpty = false;
						// sl.AddTail(path + file.name);
					}
				} while (FindNextFile(hFile, &wfd));

				FindClose(hFile);
			}

			// TODO: use 'sl' in the next step to find files (already a nice speedup as it is now...)
			if (fEmpty) {
				continue;
			}

			for (ptrdiff_t j = 0; j < extlistnum; j++) {
				for (ptrdiff_t i = 0; i < extsubnum; i++) {
					if ((hFile = FindFirstFile(path + title + ext[j][i], &wfd)) != INVALID_HANDLE_VALUE) {
						do {
							CString fn = path + wfd.cFileName;

							hFile2 = INVALID_HANDLE_VALUE;

							if (j == 0 || (hFile2 = FindFirstFile(fn.Left(fn.ReverseFind('.')) + _T(".avi"), &wfd2)) == INVALID_HANDLE_VALUE) {
								SubFile f;
								f.fn = fn;
								ret.Add(f);
							}

							if (hFile2 != INVALID_HANDLE_VALUE) {
								FindClose(hFile2);
							}
						} while (FindNextFile(hFile, &wfd));

						FindClose(hFile);
					}
				}
			}
		}
	} else if (l > 7) {
		CWebTextFile wtf; // :)
		if (wtf.Open(orgpath + title + WEBSUBEXT)) {
			CString fn;
			while (wtf.ReadString(fn) && fn.Find(_T("://")) >= 0) {
				SubFile f;
				f.fn = fn;
				ret.Add(f);
			}
		}
	}

	// sort files, this way the user can define the order (movie.00.English.srt, movie.01.Hungarian.srt, etc)

	qsort(ret.GetData(), ret.GetCount(), sizeof(SubFile), SubFileCompare);
}