Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
74da5425
Commit
74da5425
authored
Aug 12, 2007
by
Pierre d'Herbemont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modules/meta_engine/googleimage.c: Art Fetcher module that gets it's arts from images.google.com.
parent
4af2ccf4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
158 additions
and
0 deletions
+158
-0
configure.ac
configure.ac
+1
-0
modules/meta_engine/Modules.am
modules/meta_engine/Modules.am
+1
-0
modules/meta_engine/googleimage.c
modules/meta_engine/googleimage.c
+156
-0
No files found.
configure.ac
View file @
74da5425
...
@@ -1209,6 +1209,7 @@ VLC_ADD_PLUGINS([access_filter_bandwidth])
...
@@ -1209,6 +1209,7 @@ VLC_ADD_PLUGINS([access_filter_bandwidth])
VLC_ADD_PLUGINS([packetizer_mpegvideo packetizer_h264])
VLC_ADD_PLUGINS([packetizer_mpegvideo packetizer_h264])
VLC_ADD_PLUGINS([packetizer_mpeg4video packetizer_mpeg4audio])
VLC_ADD_PLUGINS([packetizer_mpeg4video packetizer_mpeg4audio])
VLC_ADD_PLUGINS([packetizer_vc1])
VLC_ADD_PLUGINS([packetizer_vc1])
VLC_ADD_PLUGINS([googleimage])
if test "${SYS}" != "mingwce"; then
if test "${SYS}" != "mingwce"; then
...
...
modules/meta_engine/Modules.am
View file @
74da5425
SOURCES_musicbrainz = musicbrainz.c
SOURCES_musicbrainz = musicbrainz.c
SOURCES_folder = folder.c
SOURCES_folder = folder.c
SOURCES_taglib = taglib.cpp
SOURCES_taglib = taglib.cpp
SOURCES_googleimage = googleimage.c
SOURCES_id3tag = id3tag.c id3genres.h $(NULL)
SOURCES_id3tag = id3tag.c id3genres.h $(NULL)
modules/meta_engine/googleimage.c
0 → 100644
View file @
74da5425
/*****************************************************************************
* googleimage.c
*****************************************************************************
* Copyright (C) 2006 the VideoLAN team
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h>
/* malloc(), free() */
#include <vlc/vlc.h>
#include <vlc_input.h>
#include <vlc_playlist.h>
#include <vlc_meta.h>
#include <vlc_stream.h>
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
FindArt
(
vlc_object_t
*
);
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_shortname
(
N_
(
"GoogleImage"
)
);
set_description
(
_
(
"Fetch Artwork from Google Images"
)
);
/* Go to image.google.com and download the first image closest to the
* title */
set_capability
(
"art finder"
,
30
);
set_callbacks
(
FindArt
,
NULL
);
vlc_module_end
();
/*****************************************************************************
*****************************************************************************/
static
const
char
*
kpsz_google_image_server
=
"images.google.com"
;
static
const
char
*
kpsz_first_image_token
=
"imgurl="
;
static
int
FindArt
(
vlc_object_t
*
p_this
)
{
playlist_t
*
p_playlist
=
(
playlist_t
*
)
p_this
;
char
*
request
,
*
fname
,
*
psz
;
stream_t
*
p_stream
;
unsigned
int
count
;
unsigned
int
i
;
input_item_t
*
p_item
=
(
input_item_t
*
)(
p_playlist
->
p_private
);
char
psz_buffer
[
65536
];
/* XXX: We might want to lower that */
assert
(
p_item
);
if
(
!
p_item
->
p_meta
||
!
p_item
->
p_meta
->
psz_title
)
{
if
(
!
p_item
->
psz_name
)
{
msg_Dbg
(
p_this
,
"item has no name"
);
return
VLC_EGENERIC
;
}
fname
=
strdup
(
p_item
->
psz_name
);
}
else
{
fname
=
strdup
(
p_item
->
p_meta
->
psz_title
);
}
/* If there is a .xxx remove it, we get bad matches with it */
count
=
strlen
(
fname
);
if
(
count
>
4
&&
fname
[
count
-
4
]
==
'.'
)
fname
[
count
-
4
]
=
0
;
/* Replace some special char by + */
for
(
i
=
0
;
i
<
strlen
(
fname
);
i
++
)
{
if
(
fname
[
i
]
==
' '
||
fname
[
i
]
==
'-'
||
fname
[
i
]
==
'.'
)
fname
[
i
]
=
'+'
;
}
asprintf
(
&
request
,
"http://%s/images?q=%s&ie=UTF-8"
,
kpsz_google_image_server
,
fname
);
free
(
fname
);
msg_Dbg
(
p_this
,
"going to request %s"
,
request
);
/* Sending the request */
p_stream
=
stream_UrlNew
(
p_playlist
,
request
);
free
(
request
);
if
(
!
p_stream
)
{
msg_Err
(
p_this
,
"Can't connect"
);
return
VLC_EGENERIC
;
}
/* The access will return the whole page at once, we just abuse from that */
count
=
stream_Read
(
p_stream
,
(
uint8_t
*
)
psz_buffer
,
sizeof
(
psz_buffer
)
-
1
);
if
(
count
<=
0
)
{
msg_Warn
(
p_this
,
"Can't read the page"
);
stream_Delete
(
p_stream
);
return
VLC_EGENERIC
;
}
psz_buffer
[
count
]
=
0
;
/* Find the first occurences of kpsz_first_image_token */
if
(
!
(
psz
=
strstr
(
psz_buffer
,
kpsz_first_image_token
))
)
{
msg_Warn
(
p_this
,
"No image found"
);
stream_Delete
(
p_stream
);
return
VLC_EGENERIC
;
}
/* Found */
psz
+=
7
;
/* Now get the end of the link */
fname
=
psz
;
psz
=
strchr
(
fname
,
'&'
);
if
(
!
psz
)
{
msg_Dbg
(
p_this
,
"Invalid page (or chunk) (!)"
);
stream_Delete
(
p_stream
);
return
VLC_EGENERIC
;
}
*
psz
=
0
;
/* fname points to the url */
stream_Delete
(
p_stream
);
/* We have the link */
msg_Dbg
(
p_this
,
"Image is at '%s'
\n
"
,
fname
);
vlc_meta_SetArtURL
(
p_item
->
p_meta
,
fname
);
return
VLC_SUCCESS
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment