peek icon indicating copy to clipboard operation
peek copied to clipboard

Imgur upload functionality

Open gort818 opened this issue 7 years ago • 32 comments

Added libsoup and json-glib so we can use the imgur api to do an HTTPS POST, and parse the json that is returned.

@phw let's keep this open as I push changes to this branch

gort818 avatar Apr 13 '18 14:04 gort818

Added a bunch more goodies, still a lot of work to do. But the imgur upload is working, should I have a gtk text box to show the link of the file or just have it open in a web browser?

Take a look when you get a chance it is still pretty messy atm.

TODO:

  1. ~~Add error handling for the json parser.~~
  2. Add functionality for opening in file manager
  3. What to do with the imgur link when finished uploading.
  4. Clean up code.

gort818 avatar Apr 29 '18 19:04 gort818

Just a side note we cannot upload webm files to imgur. https://help.imgur.com/hc/en-us/articles/115000083326-What-files-can-I-upload-What-is-the-size-limit- ~~And for some reason I cannot get mp4 files to upload.~~ Edit: Imgur does not support mp4 uploads through their api :(

gort818 avatar May 02 '18 01:05 gort818

Hey,

Would you like giving a try to Up2Share instead (https://up2sha.re)? I’m looking for an app that can serve as a desktop client to record image/gif/videos.

We support webm/mp4/gif uploads and previews as well. The current API is behind an API token but I’m sure we can work on public endpoints easily.

Let me know what you think.

cocochepeau avatar May 06 '18 16:05 cocochepeau

@cocochepeau once we get this branch merged we will look into other options for uploads, thanks for the heads up!

gort818 avatar May 09 '18 14:05 gort818

Thanks - feel free to ping me if you need anything. :)

cocochepeau avatar May 11 '18 12:05 cocochepeau

@phw everything seems to function well enough, I am not sure how to proceed when you get a chance can you give this a test. I am going to need some help integrating this.. not sure what is the best way yet.

gort818 avatar May 15 '18 18:05 gort818

@phw Have you had any time to take a look yet?

gort818 avatar Jun 07 '18 14:06 gort818

Thanks for taking the time to review this! I will take a look this week and make some changes!

gort818 avatar Jun 13 '18 23:06 gort818

Was out of town the past week, trying to get this done soon, sorry for the delay.

gort818 avatar Jun 28 '18 01:06 gort818

my old thinkpad died on me:( just got a new laptop.. sorry for the delay

gort818 avatar Jul 14 '18 22:07 gort818

No worries, I just came back from vacation and catching up on stuff :)

phw avatar Jul 15 '18 11:07 phw

Finally go around to it, thanks for your suggestions all made perfect sense. take a look :)

gort818 avatar Jul 20 '18 02:07 gort818

I just remembered we switch to meson, going to have to make some changes to the build file.

gort818 avatar Aug 30 '18 18:08 gort818

Ok now works great with meson, just need to have libsoup installed.

gort818 avatar Sep 22 '18 00:09 gort818

@phw Love it you could take another look :)

gort818 avatar Oct 25 '18 00:10 gort818

Hello there! It would be a great feature, but i'm not sure if should be a built-in feature.

I'm a fan of Shutter for image capture and editing and because it lack upload to diferent servers a wrote this code that listen for changes in a folder and upload it to Dropbox. https://github.com/jcarizza/drosh/

Maybe we can make a side project that listen for new files and upload them to Imgur, Dropbox or what ever.

jcarizza avatar Apr 26 '19 17:04 jcarizza

any progress on this ? would hate to see this rot

luzpaz avatar Sep 04 '19 20:09 luzpaz

@luzpaz it works haven't touched the code for months, haven't had anyone test it out.., give it a test drive :) waiting for @phw to take another look.

gort818 avatar Sep 04 '19 21:09 gort818

@gort818 i will be happy to test. Just need a hand with building it. In the README it says:

meson --prefix=/usr/local builddir
cd builddir
ninja

# Run directly from source
./peek

# Install system-wide
sudo ninja install

first question: how do i create test binary without polluting my currently installed peek app? I think this may be called an 'out of source build' right?

second question: sudo ninja install i can skip this correct ?

source: https://github.com/phw/peek#from-source

luzpaz avatar Sep 05 '19 13:09 luzpaz

@luzpaz Yeah just skip the install command, and just run ./peek from the build directory.

gort818 avatar Sep 06 '19 17:09 gort818

@gort818 I pulled your branch, I ran the following:

meson --prefix=/usr/local builddir
cd builddir
ninja

but the peek binary wasn't created.

luzpaz avatar Sep 07 '19 03:09 luzpaz

[foo@foo peek]$ meson --prefix=/usr/bin builddir
The Meson build system
Version: 0.51.2
Source dir: /home/foo/Projects/peek
Build dir: /home/foo/Projects/peek/builddir
Build type: native build
Project name: peek
Project version: 1.3.1
C compiler for the host machine: cc (gcc 9.1.0 "cc (GCC) 9.1.0")
Vala compiler for the host machine: valac (valac 0.44.7)
Build machine cpu family: x86_64
Build machine cpu: x86_64
Program desktop-file-validate found: YES (/usr/bin/desktop-file-validate)
Program appstream-util found: YES (/usr/bin/appstream-util)
Program glib-compile-schemas found: YES (/usr/bin/glib-compile-schemas)
Configuring com.uploadedlobster.peek.service using configuration
Program txt2man found: YES (/usr/bin/txt2man)
Program gzip found: YES (/usr/bin/gzip)
Message: Found txt2man and gzip; man page will be built and installed
Found pkg-config: /usr/bin/pkg-config (1.6.3)
Run-time dependency gtk+-3.0 found: YES 3.24.10
Run-time dependency keybinder-3.0 found: YES 0.3.2
Run-time dependency cairo found: YES 1.17.3
Run-time dependency gio-2.0 found: YES 2.60.6
Run-time dependency glib-2.0 found: YES 2.60.6
Run-time dependency gmodule-2.0 found: YES 2.60.6
Run-time dependency libsoup-2.4 found: YES 2.66.2
Run-time dependency json-glib-1.0 found: YES 1.4.4
Message: Compiling with features for GTK >= 3.16
Message: Compiling with features for GTK >= 3.20
Message: Compiling with features for GTK >= 3.22
Configuring about.ui using configuration
Found pkg-config: /usr/bin/pkg-config (1.6.3)
Dependency gtk+-3.0 found: YES (cached)
Dependency gtk+-3.0 found: YES (cached)
Dependency gtk+-3.0 found: YES (cached)
Program build-aux/meson/postinstall.py found: YES (/home/foo/Projects/peek/build-aux/meson/postinstall.py)
Build targets in project: 13
Found ninja-1.9.0 at /usr/bin/ninja

[foo@foo peek]$ cd builddir/

[foo@foo builddir]$ ninja

[2/66] Generating peek.1.txt with a custom command.
gawk: cmd. line:58: warning: regexp escape sequence `\o' is not a known regexp operator
gawk: cmd. line:116: warning: regexp escape sequence `\,' is not a known regexp operator
gawk: cmd. line:116: warning: regexp escape sequence `\;' is not a known regexp operator
[11/66] Compiling Vala source ../tests/screen-recorder/test-cli-screen-recor...Projects/peek/src/errordomain.vala /home/foo/Projects/peek/src/utils.vala.
/home/foo/Projects/peek/src/recording/recording-area.vala:43.26-43.41: warning: Gdk.Screen.get_width has been deprecated since 3.22
/home/foo/Projects/peek/src/recording/recording-area.vala:44.27-44.43: warning: Gdk.Screen.get_height has been deprecated since 3.22
Compilation succeeded - 2 warning(s)
[14/66] Compiling Vala source ../src/vapi/config.vapi ../src/main.vala ../sr...ences-dialog.vala ../src/ui/share-dialog.vala ../src/ui/shortcut-label.vala.
../src/recording/recording-area.vala:43.26-43.41: warning: Gdk.Screen.get_width has been deprecated since 3.22
../src/recording/recording-area.vala:44.27-44.43: warning: Gdk.Screen.get_height has been deprecated since 3.22
../src/ui/application-window.vala:197.5-197.27: warning: method `Peek.Ui.ApplicationWindow.get_file' never used
    public  string get_file(){
    ^^^^^^^^^^^^^^^^^^^^^^^
../src/ui/share-dialog.vala:81.5-81.33: warning: method `Peek.Ui.ShareDialog.open_file_manager' never used
    public void open_file_manager () {
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Compilation succeeded - 4 warning(s)
[66/66] Linking target tests/test-cli-screen-recorder.

luzpaz avatar Sep 07 '19 03:09 luzpaz

@luzpaz It compiled successfully . I don't remember where it puts the executable in builddir/src

gort818 avatar Sep 07 '19 03:09 gort818

@gort818
ok, found it. not sure why I didn't see it before. I wonder if it's from my previous installation attempts. It crashes on loading. Here is the backtrace:

Starting program: /home/foo/Projects/peek/builddir/src/peek 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7ffff291d700 (LWP 20259)]
[New Thread 0x7ffff211c700 (LWP 20260)]
[New Thread 0x7ffff1797700 (LWP 20261)]

(peek:20255): GLib-GIO-ERROR **: 00:03:38.290: Settings schema 'com.uploadedlobster.peek' is not installed

Thread 1 "peek" received signal SIGTRAP, Trace/breakpoint trap.
0x00007ffff7b644e6 in ?? () from /usr/lib/libglib-2.0.so.0
(gdb) bt
#0  0x00007ffff7b644e6 in  () at /usr/lib/libglib-2.0.so.0
#1  0x00007ffff7b58cf6 in g_log_default_handler () at /usr/lib/libglib-2.0.so.0
#2  0x00007ffff7b6471d in g_logv () at /usr/lib/libglib-2.0.so.0
#3  0x00007ffff7b5af80 in g_log () at /usr/lib/libglib-2.0.so.0
#4  0x00007ffff7d07e1d in  () at /usr/lib/libgio-2.0.so.0
#5  0x00007ffff7c599a5 in  () at /usr/lib/libgobject-2.0.so.0
#6  0x00007ffff7c5a1b9 in g_object_new_valist () at /usr/lib/libgobject-2.0.so.0
#7  0x00007ffff7c5ab2a in g_object_new () at /usr/lib/libgobject-2.0.so.0
#8  0x0000555555565e60 in peek_application_get_app_settings () at ../src/application.vala:47
#9  0x0000555555566dd3 in peek_application_register_key_bindings (self=0x5555555e7100) at ../src/application.vala:202
#10 0x00005555555661a1 in peek_application_real_startup (base=0x5555555e7100) at ../src/application.vala:103
#11 0x00007ffff7c54caa in g_closure_invoke () at /usr/lib/libgobject-2.0.so.0
#12 0x00007ffff7c42854 in  () at /usr/lib/libgobject-2.0.so.0
#13 0x00007ffff7c4689a in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0
#14 0x00007ffff7c47700 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#15 0x00007ffff7d1ad91 in g_application_register () at /usr/lib/libgio-2.0.so.0
#16 0x00007ffff7d1b80c in  () at /usr/lib/libgio-2.0.so.0
#17 0x00007ffff7d1b536 in g_application_run () at /usr/lib/libgio-2.0.so.0
#18 0x0000555555565d70 in _vala_main (args=0x7fffffffd898, args_length1=1) at ../src/main.vala:27
#19 0x0000555555565db3 in main (argc=1, argv=0x7fffffffd898) at ../src/main.vala:13

Sorry

luzpaz avatar Sep 07 '19 04:09 luzpaz

@luzpaz ok I updated it .. should work now give it a shot :)

gort818 avatar Sep 07 '19 05:09 gort818

rebased and built. Still crashes:

(peek:27066): GLib-GIO-ERROR **: 01:44:11.798: Settings schema 'com.uploadedlobster.peek' is not installed

Thread 1 "peek" received signal SIGTRAP, Trace/breakpoint trap.
0x00007ffff7b644e6 in ?? () from /usr/lib/libglib-2.0.so.0
(gdb) bt
#0  0x00007ffff7b644e6 in  () at /usr/lib/libglib-2.0.so.0
#1  0x00007ffff7b58cf6 in g_log_default_handler () at /usr/lib/libglib-2.0.so.0
#2  0x00007ffff7b6471d in g_logv () at /usr/lib/libglib-2.0.so.0
#3  0x00007ffff7b5af80 in g_log () at /usr/lib/libglib-2.0.so.0
#4  0x00007ffff7d07e1d in  () at /usr/lib/libgio-2.0.so.0
#5  0x00007ffff7c599a5 in  () at /usr/lib/libgobject-2.0.so.0
#6  0x00007ffff7c5a1b9 in g_object_new_valist () at /usr/lib/libgobject-2.0.so.0
#7  0x00007ffff7c5ab2a in g_object_new () at /usr/lib/libgobject-2.0.so.0
#8  0x0000555555564da0 in peek_application_get_app_settings () at ../src/application.vala:47
#9  0x0000555555565d07 in peek_application_register_key_bindings (self=0x5555555e6100) at ../src/application.vala:198
#10 0x00005555555650d5 in peek_application_real_startup (base=0x5555555e6100) at ../src/application.vala:99
#11 0x00007ffff7c54caa in g_closure_invoke () at /usr/lib/libgobject-2.0.so.0
#12 0x00007ffff7c42854 in  () at /usr/lib/libgobject-2.0.so.0
#13 0x00007ffff7c4689a in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0
#14 0x00007ffff7c47700 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#15 0x00007ffff7d1ad91 in g_application_register () at /usr/lib/libgio-2.0.so.0
#16 0x00007ffff7d1b80c in  () at /usr/lib/libgio-2.0.so.0
#17 0x00007ffff7d1b536 in g_application_run () at /usr/lib/libgio-2.0.so.0
#18 0x0000555555564cb0 in _vala_main (args=0x7fffffffd898, args_length1=1) at ../src/main.vala:27
#19 0x0000555555564cf3 in main (argc=1, argv=0x7fffffffd898) at ../src/main.vala:13

luzpaz avatar Sep 07 '19 05:09 luzpaz

@luzpaz I should have read your error :(

(peek:27066): GLib-GIO-ERROR **: 01:44:11.798: Settings schema 'com.uploadedlobster.peek' is not installed

copy data/com.uploadedlobster.peek.gschema.xml to /usr/local/share/glib-2.0/schemas/ and then

run:

glib-compile-schemas /usr/local/share/glib-2.0/schemas/

gort818 avatar Sep 07 '19 05:09 gort818

I'll try tomorrow. Will report then

luzpaz avatar Sep 07 '19 05:09 luzpaz

@luzpaz did you give it a test?

gort818 avatar Sep 17 '19 00:09 gort818

Yea, tried but needed to reset my environment. Will try again in the next few days. Sorry for keeping you hanging.

luzpaz avatar Sep 17 '19 16:09 luzpaz