示例#1
0
bool CFanart::DownloadThumb(unsigned int index, const CStdString &strDestination) const
{
    if (index >= m_fanart.size())
        return false;

    CStdString thumbURL;
    if (!m_fanart[index].strPreview.IsEmpty())
    {
        if (m_url.IsEmpty())
            thumbURL = m_fanart[index].strPreview;
        else
            thumbURL = URIUtils::AddFileToFolder(m_url, m_fanart[index].strPreview);

        XFILE::CFileCurl http;
        if (http.Download(thumbURL, strDestination))
            return true;
    }

    // try downloading the image instead
    if (m_url.IsEmpty())
        thumbURL = m_fanart[index].strImage;
    else
        thumbURL = URIUtils::AddFileToFolder(m_url, m_fanart[index].strImage);
    return DownloadImage(thumbURL, strDestination);
}
示例#2
0
void CMyCrawler::SearchUrl(const string &startUrl)
{
	string txt;
	if (!GetWebResponse(startUrl, txt))
		return;
	string filename=ChangeToFileName(startUrl);
	filename = "./html/" + filename + ".txt";
	ofstream outfile(filename.c_str());
	if (!outfile){
		cout << "error:unable to open file:" << filename << endl;
		return;
	}
	outfile << txt;
	outfile.close();
	vector<string> imgUrls;
	GetImageUrl(imgUrls, txt, startUrl);
	DownloadImage(imgUrls, startUrl);
}
示例#3
0
stLoadStatus CImageHandler::LoadNext()
{
	stLoadStatus stReturn;

	stReturn.iNumberLoaded	= m_pImageList->GetCountPopped();
	stReturn.iTotalCount	= m_pImageList->GetCountLoaded();
	stReturn.eObjectLoaded = ImageLoaded;

	if ( m_pImageList->GetCountLeft() == 0 )
	{
		stReturn.sStatus = "Finished!";
		m_bLoadFinished = true;

		if ( m_pImageList != 0 )
			delete m_pImageList;
		m_pImageList = 0;

		return stReturn;
	}

	string sWikiFileName	= GetUntilFirst( m_pImageList->GetTagText(), "|" );
	string sSaveToFileName	= GetAfterLast ( m_pImageList->GetTagText(), "|" );
	
	// Does the image already exist?
	if ( DoesGameMediaExist( pEngine->GetGameDir(), sSaveToFileName ) == false )
	{
		DownloadImage( sWikiFileName, g_sAppDir+ "\\Media\\" + pEngine->GetGameDir() + "\\" + sSaveToFileName );
	}

	m_sLastImage = sSaveToFileName;

	stReturn.sStatus = "Image \"" + sWikiFileName + "\" downloaded";

	m_pImageList->Pop();

	return stReturn;
}
示例#4
0
// -------------------------------------------------------------------------------- //
bool DownloadImage( const wxString &source, const wxString &target, int maxwidth, int maxheight )
{
    return DownloadImage( source, target, wxBITMAP_TYPE_JPEG, maxwidth, maxheight );
}
示例#5
0
bool CFanart::DownloadImage(const CStdString &strDestination) const
{
    if (m_fanart.size() == 0)
        return false;
    return DownloadImage(GetImageURL(), strDestination);
}
示例#6
0
 const void* Instance::GetBuffer(unsigned int y)
 {
   DownloadImage();
   return reader_->GetConstRow(y);
 }
示例#7
0
 const void* Instance::GetBuffer()
 {
   DownloadImage();
   return reader_->GetConstBuffer();
 }
示例#8
0
 Orthanc::PixelFormat Instance::GetPixelFormat()
 {
   DownloadImage();
   return reader_->GetFormat();
 }
示例#9
0
 unsigned int Instance::GetPitch()
 {
   DownloadImage();
   return reader_->GetPitch();
 }
示例#10
0
 unsigned int Instance::GetHeight() 
 {
   DownloadImage();
   return reader_->GetHeight();
 }
示例#11
0
// -------------------------------------------------------------------------------- //
guJamendoDownloadThread::ExitCode guJamendoDownloadThread::Entry()
{
    int Count;
    int LoopCount = 0;
    guConfig * Config = ( guConfig * ) guConfig::Get();
    int AudioFormat = Config->ReadNum( CONFIG_KEY_JAMENDO_AUDIOFORMAT, 1, CONFIG_PATH_JAMENDO );
    wxString TorrentCmd = Config->ReadStr( CONFIG_KEY_JAMENDO_TORRENT_COMMAND, wxEmptyString, CONFIG_PATH_JAMENDO );
    while( !TestDestroy() )
    {
        m_CoversMutex.Lock();
        Count = m_Covers.Count();
        m_CoversMutex.Unlock();

        size_t CurTime = wxGetLocalTimeMillis().GetLo();
        if( Count )
        {
            LoopCount = 0;
            wxString CoverFile = guPATH_JAMENDO_COVERS;
            CoverFile += wxString::Format( wxT( "%u.jpg" ), m_Covers[ 0 ] );

            if( !wxFileExists( CoverFile ) )
            {
                if( !wxDirExists( wxPathOnly( CoverFile ) + wxT( "/" ) ) )
                {
                    wxMkdir( wxPathOnly( CoverFile ) + wxT( "/" ), 0770 );
                }
                wxString CoverUrl = wxString::Format( guJAMENDO_COVER_DOWNLOAD_URL, m_Covers[ 0 ], 300 );
                DownloadImage( CoverUrl, CoverFile, 300 );
            }

            if( wxFileExists( CoverFile ) )
            {
                int CoverId = m_Db->AddCoverFile( CoverFile );

                wxString query = wxString::Format( wxT( "UPDATE songs SET song_coverid = %u WHERE song_albumid = %u" ),
                                    CoverId, m_Covers[ 0 ] );

                m_Db->ExecuteUpdate( query );

                // Notify the panel that the cover is downloaded
                wxCommandEvent event( wxEVT_MENU, ID_JAMENDO_COVER_DOWNLAODED );
                event.SetInt( m_Covers[ 0 ] );
                wxPostEvent( m_MediaViewer, event );
            }
            else
            {
                guLogMessage( wxT( "Could not get the jamendo cover art %s" ), CoverFile.c_str() );
            }

            m_CoversMutex.Lock();
            m_Covers.RemoveAt( 0 );
            m_CoversMutex.Unlock();
        }
        else
        {
            LoopCount++;
            if( LoopCount > 8 )
            {
                break;
            }
        }

        if( TestDestroy() )
            break;

        size_t Elapsed = wxGetLocalTimeMillis().GetLo() - CurTime;
        if( !( Elapsed > 1000 ) )
        {
            Sleep( 1000 - Elapsed );
        }

        //
        // Album Torrents
        //
        m_AlbumsMutex.Lock();
        Count = m_Albums.Count();
        m_AlbumsMutex.Unlock();

        CurTime = wxGetLocalTimeMillis().GetLo();
        if( Count )
        {
            LoopCount = 0;

            wxString Url = wxString::Format( guJAMENDO_TORRENT_DOWNLOAD_URL, m_Albums[ 0 ] );
            Url += AudioFormat ? guJAMENDO_DOWNLOAD_FORMAT_OGG : guJAMENDO_DOWNLOAD_FORMAT_MP3;

            //guLogMessage( wxT( "Getting %s" ), Url.c_str() );

            wxString TorrentUrl = GetUrlContent( Url );

            //guLogMessage( wxT( "Downloading '%s'" ), TorrentUrl.c_str() );
            if( !TorrentUrl.IsEmpty() )
            {
                wxString TmpFileName = wxFileName::CreateTempFileName( wxString::Format( wxT( "%u" ), m_Albums[ 0 ] ) );
                TmpFileName += wxT( ".torrent" );
                if( DownloadFile( TorrentUrl, TmpFileName ) )
                {
                    guExecute( TorrentCmd + wxT( " " ) + TmpFileName );
                }
            }

            m_AlbumsMutex.Lock();
            m_Albums.RemoveAt( 0 );
            m_AlbumsMutex.Unlock();
        }
        else
        {
            LoopCount++;
            if( LoopCount > 8 )
            {
                break;
            }
        }

        if( TestDestroy() )
            break;

        Elapsed = wxGetLocalTimeMillis().GetLo() - CurTime;
        if( !( Elapsed > 1000 ) )
        {
            Sleep( 1000 - Elapsed );
        }
    }
    return 0;
}
示例#12
0
	void ThreadFunc(void* args){
		//checking if we have right args
		if(!args)
			return;
		
		//getting thread info
		ThreadInfo* t = (ThreadInfo*)args;

		uint CurImage = 0;
		t->CurImage = 0;

		//main loop
		do{
			//checking if thread is paused
			WaitForSingleObject(t->Running, INFINITE);

			//checking if thread is not terminated
			if(!t->Terminate){
				//checking if we need list and downloading it
				if(!t->ResultList){
					t->ResultList = flickcurl_photos_search_params(t->Flickcurl, 
						&t->SearchParams, &t->ListParams);

					if(t->ResultList)
						t->TotalImages = t->ResultList->total_count;
					
					CurImage = 0;
					t->ListParams.page++; //updating page
				}

				//checking if anything were found
				if(t->ResultList){
					t->CurImage++;

					//creating new image
					Image* img = new(Image);
					InitImage(img);

					//downloading photo meta if needed
					if(t->WantMeta)
						img->Meta = flickcurl_photos_getInfo(t->Flickcurl, t->ResultList->photos[CurImage]->id);
				
					//downloading photo exif if needed
					if(t->WantEXIF)
						img->EXIF = flickcurl_photos_getExif(t->Flickcurl, t->ResultList->photos[CurImage]->id,
									t->ResultList->photos[CurImage]->fields[PHOTO_FIELD_secret].string);
				
					//downloading photo itself if needed
					if(t->WantImage)
						img->Img = DownloadImage(t, t->ResultList->photos[CurImage]);

					//checking if we've got any data
					if(img->EXIF || img->Img != "" || img->Meta)
						AddCache(t, img); //adding to cache
					else
						FreeImage(img); //or killing intance

					//updating image number
					if(CurImage < t->ResultList->photos_count - 1)
						CurImage++;
					else{
						CurImage = 0;
						flickcurl_free_photos_list(t->ResultList);
						t->ResultList = 0;
					}
				}else
					if(!t->Terminate)
						ResetEvent(t->Running); //pause thread if nothing were found
			}
		}while(!t->Terminate);
	};