|
Post by alexfish on Oct 20, 2022 15:53:07 GMT 1
Hi all whilst there are many howto http..etc here tested lib soup (reason here see if can speed up the navigation apps download images) it seems to be the core lib for getting data and images RE osmmaps although can test where to test the session , global or local requires libsoup generally 2.4 : or check version here we go PRAGMA INCLUDE <libsoup/soup.h> PRAGMA INCLUDE <glib/gstdio.h> PRAGMA OPTIONS `pkg-config --cflags libsoup-2.4` PRAGMA LDFLAGS `pkg-config --libs libsoup-2.4` OPTION PARSE FALSE
FUNCTION SOUP(STRING MODE$,STRING URL$) TYPE STRING LOCAL session TYPE SoupSession * LOCAL msg TYPE SoupMessage * session = soup_session_new() msg = soup_message_new (MODE$, URL$) soup_session_send_message (session, msg) RETURN (STRING)msg->response_body->data
END FUNCTION
MSG$ = SOUP ("GET", "https://www.basic-converter.org")
PRINT MSG$
HOWTO HEREAlex
|
|
|
Post by bigbass on Oct 20, 2022 18:19:01 GMT 1
Hello Alex Thanks for the excellent demo very clear and to the point There is a lot that could be done with libsoup! Glad to see that you added a demo for BaCon use Joe P.S I tested this on Manjaro libsoup is preinstalled pacman -Qi libsoup Description : HTTP client/server library for GNOME Architecture : aarch64 URL : wiki.gnome.org/Projects/libsoupLicenses : LGPL
|
|
|
Post by alexfish on Oct 20, 2022 20:39:17 GMT 1
Hi Joe Thanks thought try html2text using EXEC$ html2text must be installed , check so now have Bacon HTML2TEXT here we go PRAGMA INCLUDE <libsoup/soup.h> PRAGMA INCLUDE <glib/gstdio.h> PRAGMA OPTIONS `pkg-config --cflags libsoup-2.4` PRAGMA LDFLAGS `pkg-config --libs libsoup-2.4` OPTION PARSE FALSE
FUNCTION SOUP(STRING MODE$,STRING URL$) TYPE STRING LOCAL session TYPE SoupSession * LOCAL msg TYPE SoupMessage * session = soup_session_new() msg = soup_message_new (MODE$, URL$) soup_session_send_message (session, msg)
RETURN (STRING)msg->response_body->data
END FUNCTION
MSG$ = SOUP ("GET", "https://www.basic-converter.org") MSG$ = EXEC$("html2text",MSG$) PRINT MSG$
BR Alex Picky : excuse the cropped (left side) still not got used to this flameshot Attachments:
|
|
|
Post by alexfish on Oct 20, 2022 21:09:53 GMT 1
Hi All
another example use of BaCon , can be applied to most of Bacon examples of http request demo's +one to reference the links
PRAGMA INCLUDE <libsoup/soup.h> PRAGMA INCLUDE <glib/gstdio.h> PRAGMA OPTIONS `pkg-config --cflags libsoup-2.4` PRAGMA LDFLAGS `pkg-config --libs libsoup-2.4` OPTION PARSE FALSE
FUNCTION SOUP(STRING MODE$,STRING URL$) TYPE STRING LOCAL session TYPE SoupSession * LOCAL msg TYPE SoupMessage * session = soup_session_new() msg = soup_message_new (MODE$, URL$) soup_session_send_message (session, msg)
RETURN (STRING)msg->response_body->data
END FUNCTION
MSG$ = SOUP ("GET", "https://www.basic-converter.org") MSG$ = EXEC$("html2text --reference-links",MSG$) PRINT MSG$
thinking here can get the links like [239]: openal-plugin-mid.bac
should become
https://www.basic-converter.org/openal-plugin-mid.bac
try
/* * *basicsoup.bac *`pkg-config --cflags --libs libsoup-2.4` */
PRAGMA INCLUDE <libsoup/soup.h> PRAGMA INCLUDE <glib/gstdio.h> PRAGMA OPTIONS `pkg-config --cflags libsoup-2.4` PRAGMA LDFLAGS `pkg-config --libs libsoup-2.4` OPTION PARSE FALSE
FUNCTION SOUP(STRING MODE$,STRING URL$) TYPE STRING LOCAL session TYPE SoupSession * LOCAL msg TYPE SoupMessage * session = soup_session_new() msg = soup_message_new (MODE$, URL$) soup_session_send_message (session, msg)
RETURN (STRING)msg->response_body->data
END FUNCTION
MSG$ = SOUP ("GET", "https://www.basic-converter.org/openal-plugin-mid.bac") 'MSG$ = EXEC$("html2text" ,MSG$) PRINT MSG$
' can use say save file instead of PRINT
bit of the output
'------------------------------------------------------------------------------------------------------------ ' ' This is a WildMidi MIDI player plugin for the OPENAL context. PvE - MIT License 2016. ' ' Updated: added MID_BUFFER call. Code cleaning. Sept 2017 - PvE. ' ' Web address: https://github.com/Mindwerks/wildmidi ' '------------------------------------------------------------------------------------------------------------ ' ' MID_OPEN(file$) ' => Load the MIDI file, song ID is returned ' ' MID_BUFFER(memory pointer, size) ' => Point to the MIDI data in memory with length, song ID is returned ' MID_PLAY(songID) ' => Start playing the MIDI file ' ' MID_PAUSE(songID) ' => Pause playing the MIDI file ' ' MID_STOP(songID) ' => Stop playing the MIDI file ' ' MID_UPDATE(songID) ' => Keep the OpenAL buffers filled, to be used in callback function. ' ' MID_BUSY(songID) ' => Check if we're still playing (TRUE) or not e.g. song is finished (FALSE) ' ' MID_VOLUME(songID, volume) ' => Set the volume of the source in range 0.0 - 1.0 ' ' MID_CLOSE(songID) ' => Free resources for the current file ' ' MID_FREE ' => Free all memory resources for the complete MIDI context ' '------------------------------------------------------------------------------------------------------------
BR Alex
|
|
|
Post by alexfish on Oct 20, 2022 21:38:15 GMT 1
Hi All if have a scrollback terminal with copy and paste 'Simple Bacon Text Browser: to be expanded on by all can try /* * *basicsoup.bac *`pkg-config --cflags --libs libsoup-2.4` */
PRAGMA INCLUDE <libsoup/soup.h> PRAGMA INCLUDE <glib/gstdio.h> PRAGMA OPTIONS `pkg-config --cflags libsoup-2.4` PRAGMA LDFLAGS `pkg-config --libs libsoup-2.4` OPTION PARSE FALSE
FUNCTION SOUP(STRING MODE$,STRING URL$) TYPE STRING LOCAL session TYPE SoupSession * LOCAL msg TYPE SoupMessage * session = soup_session_new() msg = soup_message_new (MODE$, URL$) soup_session_send_message (session, msg)
RETURN (STRING)msg->response_body->data
END FUNCTION
MSG$ = SOUP ("GET", "https://www.basic-converter.org/") MSG$ = EXEC$("html2text --reference-links" ,MSG$) PRINT MSG$
PRINT " Which link " ; INPUT A$ PRINT " You picked -> " , A$ example say Konsole ./basicsoup tail of but scroll up to see all links then copy the the bit after [*]: [372]: http://c.statcounter.com/4570091/0/fdd8a455/0/
[373]: http://www.statcounter.com/wordpress.com/ (counter for wordpress)
[374]: http://www.blacktie.co
Which link documentation.txt You picked -> documentation.txt
BR Alex PS: "Simple Bacon Text Browser: to be expanded on by all" somewhere in those bits are images Task First one to display a sixel image in the terminal can have a free beer have posted on how to load the image the PRINT(SIXEL$); if want to embed libsixel can look HEREIn mean time getting back to maps
|
|
|
Post by alexfish on Oct 21, 2022 1:37:46 GMT 1
Hi All
been a while since using html2text
html2text --help so now have this set up, use terminal that has copy and paste menu xterm not good for this type of terminal app some terminals behave like text widget, for test i used Konsole , backspace delete is brill
+ maximize the window
/* * *basicsoup.bac *`pkg-config --cflags --libs libsoup-2.4` */
PRAGMA INCLUDE <libsoup/soup.h> PRAGMA INCLUDE <glib/gstdio.h> PRAGMA OPTIONS `pkg-config --cflags libsoup-2.4` PRAGMA LDFLAGS `pkg-config --libs libsoup-2.4` OPTION PARSE FALSE
FUNCTION SOUP(STRING MODE$,STRING URL$) TYPE STRING LOCAL session TYPE SoupSession * LOCAL msg TYPE SoupMessage * session = soup_session_new() msg = soup_message_new (MODE$, URL$) soup_session_send_message (session, msg)
RETURN (STRING)msg->response_body->data
END FUNCTION
MSG$ = SOUP ("GET", "https://www.basic-converter.org/") MSG$ = EXEC$("html2text --protect-links --images-as-html " ,MSG$) PRINT MSG$
PRINT "Select Link :" ; INPUT A$ PRINT "LINK " ,A$
BR Alex
|
|
|
Post by alexfish on Oct 21, 2022 3:30:57 GMT 1
Hi All with this sort app thought would try bacon -e (console editor) with Konsol think closest you can get to the gui version can even scroll with the mouse , eack picky speaks a thousand words they say argh well look at this Attachments:
|
|
|
Post by alexfish on Oct 21, 2022 16:15:04 GMT 1
Hi all looks like Manjaro repos are upto date back on pi os need html2markdown may apply to other os's how confusing is this install python3-html2text Example /* * *basicsoup.bac *`pkg-config --cflags --libs libsoup-2.4` */
PRAGMA INCLUDE <libsoup/soup.h> PRAGMA INCLUDE <glib/gstdio.h> PRAGMA OPTIONS `pkg-config --cflags libsoup-2.4` PRAGMA LDFLAGS `pkg-config --libs libsoup-2.4` OPTION PARSE FALSE
FUNCTION SOUP(STRING MODE$,STRING URL$) TYPE STRING LOCAL session TYPE SoupSession * LOCAL msg TYPE SoupMessage * session = soup_session_new() msg = soup_message_new (MODE$, URL$) soup_session_send_message (session, msg)
RETURN (STRING)msg->response_body->data
END FUNCTION
MSG$ = SOUP ("GET", "https://www.basic-converter.org/") MSG$ = EXEC$("html2markdown --protect-links --images-as-html " ,MSG$) PRINT MSG$ BR Alex
|
|
|
Post by bigbass on Oct 21, 2022 17:39:48 GMT 1
Hello Alex and All
was curious to try sixel in the terminal very interesting
get the lib dependency
sudo pacman -S libsixel while testing the prior demos
just for testing we could if we know what image we want beforehand do this
xterm -hold -ti vt340 -e 'wget http://www.basic-converter.org/linux.png \ | img2sixel -i linux.png -o linux.sixel \ | cat linux.sixel'
and for bacon testing would work
SYSTEM("xterm -hold -ti vt340 -e wget http://www.basic-converter.org/linux.png | img2sixel -i linux.png -o linux.sixel | cat linux.sixel")
Joe
|
|
|
Post by alexfish on Oct 21, 2022 22:22:32 GMT 1
Hi Joe This Works in this format RE pos of Xterm SYSTEM ( "wget http://www.basic-converter.org/linux.png -O linux.png | xterm -e img2sixel linux.png -o linux.six ") A$ = LOAD$("linux.six" ) PRINT A$ BR Alex Attachments:
|
|
|
Post by alexfish on Oct 21, 2022 22:31:07 GMT 1
Hi Joe
Noticed getting download logfile in the term
can sen to dev NULL or eat them with
Dump$ = EXEC$( "wget http://www.basic-converter.org/linux.png -O linux.png | xterm -e img2sixel linux.png -o linux.six ") A$ = LOAD$("linux.six" )
PRINT A$
Tip: in one of the examples possible method of getting the size of image cos that is one hell of an image RE: icon size : is not one more tip, BaCon site html wise is not clean in those terms
check the output Have Fun + BR Alex
|
|
|
Post by bigbass on Oct 22, 2022 1:41:38 GMT 1
Hello Alex
on the wget side just a -q is all we need to quiet the noise
just in case someone doesn't have the correct terminal
P.S I was reading that xfce4-terminal has sixel support I use that it is default in Manjaro xfce if we have a recent vte terminal
low resource xterm image viewer
xterm -hold -ti vt340 -e 'wget -q http://www.basic-converter.org/linux.png \ | img2sixel -i linux.png -o linux.sixel \ | cat linux.sixel'
|
|
|
Post by Pjot on Oct 22, 2022 8:27:58 GMT 1
Hi guys, It can be done in even a smaller way: SYSTEM "wget -q http://www.basic-converter.org/linux.png -O - | img2sixel"
If you're using the BaCon editor, make sure to add the option "-ti vt340" to xterm (mentioned by Joe), see screenshot. BR Peter Attachments:
|
|
|
Post by bigbass on Oct 22, 2022 14:18:52 GMT 1
Hello Alex & Peter & All Peter I like how you shortened the code thanks ! less is more or better /easier to type and remember didn't know we could pipe it to img2sixel that way a cool short cut Alex said the size of the images can be a problem libsixel is very well designed to fine tune everything we could need to do manpages.debian.org/testing/libsixel-bin/img2sixel.1.en.htmlusing the shortened version Peter posted plus a nice resize that is simple to work with xterm -hold -ti vt340 -e "wget -q http://www.basic-converter.org/linux.png -O - | img2sixel -w48 -h48"
using the debian RPI3 to test this Joe
|
|
|
Post by alexfish on Oct 22, 2022 22:10:30 GMT 1
Hi All Bacon code A$ = EXEC$("wget -q http://www.basic-converter.org/linux.png -O - | img2sixel -w48 -h48" ) PRINT A$ Peter gets a free beer BR Alex might of replied earlier, just got the seamap server up and running ADDED :: from local server A$ = EXEC$("wget -q http://192.168.8.100/bacon-osm-maps/16/32403/20484.png -O - | img2sixel " ) PRINT A$ Picky Attachments:
|
|