Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imgur upload functionality #311

Open
wants to merge 53 commits into
base: main
Choose a base branch
from
Open

Imgur upload functionality #311

wants to merge 53 commits into from

Conversation

gort818
Copy link
Contributor

@gort818 gort818 commented Apr 13, 2018

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
Copy link
Contributor Author

gort818 commented Apr 29, 2018

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.

Destroy file chooser dialog after confirming save location, as it interferes with the share dialog.
Added glib error handling, code formatting and now imgur link opens in browser.
Changed spacing between buttons.
Added #if HAS_GTK_SHOW_URI_ON_WINDOW
for users using gtk 3.22 and above.
@gort818
Copy link
Contributor Author

gort818 commented May 2, 2018

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 added 10 commits May 1, 2018 18:54
pass the file extension over to check if we can upload to imgur.
Checks for file format and deselects imgur upload option for file extentions mp4 and webm as they are not supported through the imgur upload api.
Checks for file format and deselects imgur upload option for file extentions mp4 and webm as they are not supported through the imgur upload api.
Checks for file format and deselects imgur upload option for file extentions mp4 and webm as they are not supported through the imgur upload api.
If the user used mp4 or webm print a debug message telling them it is not supported for upload to imgur.
It now centers on the parent window.
If an option is unavailable automatically select the other row and display the check image.
ex. Upload to imgur option is unavailable for mp4 and webm, it automatically select the option for opening in the file manager.
@cocochepeau
Copy link

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.

@gort818
Copy link
Contributor Author

gort818 commented May 9, 2018

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

@cocochepeau
Copy link

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

@gort818
Copy link
Contributor Author

gort818 commented May 15, 2018

@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
Copy link
Contributor Author

gort818 commented Jun 7, 2018

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

Checks for file format and deselects imgur upload option for file extentions mp4 and webm as they are not supported through the imgur upload api.
If the user used mp4 or webm print a debug message telling them it is not supported for upload to imgur.
It now centers on the parent window.
If an option is unavailable automatically select the other row and display the check image.
ex. Upload to imgur option is unavailable for mp4 and webm, it automatically select the option for opening in the file manager.
Added const variable for client id, passed the file object rather than uri,
added descriptive names of rows, and hid rows if the option is not
available, put the imgur upload code in seperate function, change the
upload to non blocking message via soup.
@gort818
Copy link
Contributor Author

gort818 commented Sep 22, 2018

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

@gort818
Copy link
Contributor Author

gort818 commented Oct 25, 2018

@phw Love it you could take another look :)

@jcarizza
Copy link

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.

@luzpaz
Copy link

luzpaz commented Sep 4, 2019

any progress on this ? would hate to see this rot

@gort818
Copy link
Contributor Author

gort818 commented Sep 4, 2019

@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.

@luzpaz
Copy link

luzpaz commented Sep 5, 2019

@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

@gort818
Copy link
Contributor Author

gort818 commented Sep 6, 2019

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

@luzpaz
Copy link

luzpaz commented Sep 7, 2019

@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
Copy link

luzpaz commented Sep 7, 2019

[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.

@gort818
Copy link
Contributor Author

gort818 commented Sep 7, 2019

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

@luzpaz
Copy link

luzpaz commented Sep 7, 2019

@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

@gort818
Copy link
Contributor Author

gort818 commented Sep 7, 2019

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

@luzpaz
Copy link

luzpaz commented Sep 7, 2019

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

@gort818
Copy link
Contributor Author

gort818 commented Sep 7, 2019

@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/

@luzpaz
Copy link

luzpaz commented Sep 7, 2019

I'll try tomorrow. Will report then

@gort818
Copy link
Contributor Author

gort818 commented Sep 17, 2019

@luzpaz did you give it a test?

@luzpaz
Copy link

luzpaz commented Sep 17, 2019

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

@luzpaz
Copy link

luzpaz commented Sep 24, 2019

@phw do you mind also testing this ?

@luzpaz
Copy link

luzpaz commented Oct 11, 2019

@phw ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants