Hello community, here is the log from the commit of package smugbatch for openSUSE:Factory checked in at Thu Apr 14 09:41:13 CEST 2011.
-------- New Changes file: --- /dev/null 2010-08-26 16:28:41.000000000 +0200 +++ /mounts/work_src_done/STABLE/smugbatch/smugbatch.changes 2010-12-11 17:33:54.000000000 +0100 @@ -0,0 +1,43 @@ +------------------------------------------------------------------- +Sat Dec 11 16:33:27 UTC 2010 - [email protected] + +- cleanup spec file with spec-cleaner. + +------------------------------------------------------------------- +Sat Dec 11 16:12:35 UTC 2010 - [email protected] + +- Support new smugmug API 1.2.2 + +------------------------------------------------------------------- +Fri Dec 19 12:00:00 UTC 2008 - [email protected] + +- fixed build +- added manpages + +------------------------------------------------------------------- +Thu Dec 11 12:00:00 UTC 2008 - [email protected] + +- Update to version 005: + Ability to create the album to upload to if it is not already present + - many thanks to troy for this feature + +------------------------------------------------------------------- +Sun Jul 27 12:00:00 UTC 2008 - [email protected] + +- Update to version 004: + lots of minor fixes + +------------------------------------------------------------------- +Sun May 18 12:00:00 UTC 2008 - [email protected] + +- Update to version 003: + added ability to have a config file for password and user id + added smugdown, seems to work for public albums, not for private yet + --quiet option to all apps. + smugls actually works properly now. + +------------------------------------------------------------------- +Thu May 01 12:00:00 UTC 2008 - [email protected] + +- Initial build version. + calling whatdependson for head-i586 New: ---- smugbatch-005.tar.bz2 smugbatch-api1.2.2.patch smugbatch.changes smugbatch.spec ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ smugbatch.spec ++++++ # # spec file for package smugbatch # # Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via http://bugs.opensuse.org/ # Name: smugbatch Group: Productivity/Graphics/Other %if 0%{?suse_version} > 1020 BuildRequires: libcurl-devel %else BuildRequires: curl-devel %endif Version: 005 Release: 1 License: GPLv2 Summary: Tools for smugmug.com Url: http://github.com/gregkh/smugbatch/tree/master Source: %{name}-%{version}.tar.bz2 Patch1: smugbatch-api1.2.2.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build %description Command line tools to access smugmug.com. Authors: -------- Greg Kroah-Hartman <[email protected]> %prep %setup -q %patch1 -p1 %build make V=1 CFLAGS="%{optflags}" %install mkdir -p %{buildroot}%{_prefix}/bin install -m 0755 smugdown smugup smugls %{buildroot}%{_prefix}/bin mkdir -p %{buildroot}%{_mandir}/man1 install -m 0644 smugls.1 smugup.1 %{buildroot}%{_mandir}/man1 %files %defattr(-,root,root) %doc RELEASE-NOTES COPYING ChangeLog %doc %{_mandir}/man1/*.gz %{_bindir}/smug* %changelog ++++++ smugbatch-api1.2.2.patch ++++++ diff --git a/smug.h b/smug.h index 37fa7b6..4f0b8c1 100644 --- a/smug.h +++ b/smug.h @@ -62,6 +62,7 @@ struct session { char *password; char *email; char *session_id; + char *su_cookie; struct list_head albums; struct list_head files_upload; struct list_head files_download; @@ -126,7 +127,7 @@ extern struct album *smug_create_album(const char *album_title, extern int smug_get_albums(struct session *session); extern int smug_read_images(struct session *session, struct album *album); extern void smug_parse_configfile(struct session *session); -extern int smug_download(struct filename *filename); +extern int smug_download(struct session *session, struct filename *filename); extern int debug; diff --git a/smug_core.c b/smug_core.c index c498516..1fc2702 100644 --- a/smug_core.c +++ b/smug_core.c @@ -41,31 +41,31 @@ static char *user_agent = "smugbatch/"SMUGBATCH_VERSION" ([email protected])"; static char *session_id_tag = "Session id"; static char *smugmug_album_list_url = - "https://api.smugmug.com/hack/rest/1.2.0/?" + "https://secure.smugmug.com/services/api/rest/1.2.2/?" "method=smugmug.albums.get" "&SessionID=%s&APIKey=%s"; static char *smugmug_album_create_url = - "https://api.smugmug.com/hack/rest/1.2.0/?" + "https://secure.smugmug.com/services/api/rest/1.2.2/?" "method=smugmug.albums.create" "&SessionID=%s&Title=%s&CategoryID=%s&AlbumTemplateID=%s"; static char *smugmug_category_list_url = - "https://api.smugmug.com/hack/rest/1.2.0/?" + "https://secure.smugmug.com/services/api/rest/1.2.2/?" "method=smugmug.categories.get" "&SessionID=%s"; static char *smugmug_quicksettings_list_url = - "https://api.smugmug.com/hack/rest/1.2.0/?" + "https://secure.smugmug.com/services/api/rest/1.2.2/?" "method=smugmug.albumtemplates.get" "&SessionID=%s"; static char *smugmug_login_url = - "https://api.smugmug.com/hack/rest/1.2.0/?" + "https://secure.smugmug.com/services/api/rest/1.2.2/?" "method=smugmug.login.withPassword" "&EmailAddress=%s&Password=%s&APIKey=%s"; static char *smugmug_logout_url = - "https://api.smugmug.com/hack/rest/1.2.0/?" + "https://secure.smugmug.com/services/api/rest/1.2.2/?" "method=smugmug.logout" "&SessionID=%s&APIKey=%s"; static char *smugmug_image_list_url = - "https://api.smugmug.com/hack/rest/1.2.0/?" + "https://secure.smugmug.com/services/api/rest/1.2.2/?" "method=smugmug.images.get" "&SessionID=%s&Heavy=1&AlbumID=%s&AlbumKey=%s"; static char *smugmug_upload_url = @@ -89,6 +89,47 @@ CURL *curl_init(void) return curl; } +static char *get_su_cookie(CURL *curl) +{ + CURLcode res; + struct curl_slist *cookies; + struct curl_slist *nc; + char *cookie = NULL; + + res = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies); + if (res != CURLE_OK) { + fprintf(stderr, "Curl curl_easy_getinfo failed: %s\n", + curl_easy_strerror(res)); + exit(1); + } + nc = cookies; + while (nc) { + char domain[50], p1[50], p2[50], p3[50], name[50], value[50]; + long unsigned int t; + int res; + + /* #HttpOnly_.smugmug.com\tTRUE\t/\tFALSE\t0\tSMSESS\t99363be4c3ceb3f153f875216539524a */ + res = + sscanf(nc->data, "%s\t%s\t%s\t%s\t%lu\t%s\t%s", domain, p1, + p2, p3, &t, name, value); + if (res == 7 && strcmp(name, "_su") == 0) { + cookie = valloc(strlen(value) + 1 + 4); + sprintf(cookie, "_su=%s", value); + } + nc = nc->next; + } + curl_slist_free_all(cookies); + return cookie; +} + +static void curl_set_cookie(CURL *curl, const char *cookie) +{ + if (cookie == NULL) + return; + + curl_easy_setopt(curl, CURLOPT_COOKIE, cookie); +} + char *my_basename(char *name) { @@ -252,6 +293,7 @@ struct session *session_alloc(void) struct session *session; session = zalloc(sizeof(*session)); + session->su_cookie = NULL; if (!session) return NULL; INIT_LIST_HEAD(&session->albums); @@ -518,6 +560,7 @@ int upload_file(struct session *session, struct filename *filename, dbg("%s is %d bytes big\n", filename->filename, (int)file_info.st_size); sprintf(url, smugmug_upload_url, filename->basename); + curl_set_cookie(curl, session->su_cookie); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_callback); @@ -532,7 +575,7 @@ int upload_file(struct session *session, struct filename *filename, sprintf(buf, "Content-MD5: %s", md5_string); dbg("%s\n", buf); headers = curl_slist_append(headers, buf); - headers = curl_slist_append(headers, "X-Smug-Version: 1.2.0"); + headers = curl_slist_append(headers, "X-Smug-Version: 1.2.2"); headers = curl_slist_append(headers, "X-Smug-ResponseType: REST"); sprintf(buf, "X-Smug-SessionID: %s", session->session_id); dbg("%s\n", buf); @@ -669,7 +712,7 @@ int smug_login(struct session *session) dbg("url = %s\n", url); curl_easy_setopt(curl, CURLOPT_URL, url); - + curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""); /* log into smugmug */ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl_buf); @@ -678,7 +721,7 @@ int smug_login(struct session *session) printf("error(%d) trying to login\n", res); return -EINVAL; } - + session->su_cookie = get_su_cookie(curl); char *rsp_stat = find_value(curl_buf->data, "rsp stat", NULL); if (!rsp_stat) return -EINVAL; @@ -721,6 +764,7 @@ int smug_logout(struct session *session) sprintf(url, smugmug_logout_url, session->session_id, api_key); dbg("url = %s\n", url); + curl_set_cookie(curl, session->su_cookie); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl_buf); @@ -756,6 +800,8 @@ int smug_get_albums(struct session *session) sprintf(url, smugmug_album_list_url, session->session_id, api_key); dbg("url = %s\n", url); + + curl_set_cookie(curl, session->su_cookie); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl_buf); @@ -803,6 +849,7 @@ char *smug_get_quicksettings_id(const char *qs_name, struct session *session) sprintf(url, smugmug_quicksettings_list_url, session->session_id); dbg("url = %s\n", url); + curl_set_cookie(curl, session->su_cookie); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl_buf); @@ -880,6 +927,7 @@ char *smug_get_category_id(const char *category_title, struct session *session) sprintf(url, smugmug_category_list_url, session->session_id); dbg("url = %s\n", url); + curl_set_cookie(curl, session->su_cookie); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl_buf); @@ -975,6 +1023,7 @@ struct album *smug_create_album(const char *album_title, free(category_id); free(qs_id); + curl_set_cookie(curl, session->su_cookie); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl_buf); @@ -1052,6 +1101,8 @@ int smug_read_images(struct session *session, struct album *album) sprintf(url, smugmug_image_list_url, session->session_id, album->id, album->key); dbg("url = %s\n", url); + + curl_set_cookie(curl, session->su_cookie); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl_buf); @@ -1073,7 +1124,7 @@ int smug_read_images(struct session *session, struct album *album) return 0; } -int smug_download(struct filename *filename) +int smug_download(struct session *session, struct filename *filename) { struct smug_curl_buffer *curl_buf; CURL *curl = NULL; @@ -1105,6 +1156,7 @@ int smug_download(struct filename *filename) dbg("3\n"); dbg("url = %s\n", filename->original_url); + curl_set_cookie(curl, session->su_cookie); curl_easy_setopt(curl, CURLOPT_URL, filename->original_url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl_buf); diff --git a/smugdown.c b/smugdown.c index 96ddab5..c338880 100644 --- a/smugdown.c +++ b/smugdown.c @@ -156,7 +156,7 @@ int main(int argc, char *argv[], char *envp[]) list_for_each_entry(temp, &session->files_download, entry) { if (strcmp(temp->filename, filename->filename) == 0) { /* we found something to download */ - smug_download(filename); + smug_download(session, filename); } } } ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun... -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
