This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

adding throttle in m00nie's youtube tcl

Support & discussion of released scripts, and announcements of new releases.
User avatar
m4s
Halfop
Posts: 97
Joined: Mon Jan 30, 2017 3:24 pm

Post by m4s »

Yes, I also got an error message. :(

[11:20] Tcl error [m00nie::youtube::autoinfo]: unable to convert date-time string "2020-05-16T11:51:42Z": more than one time zone in string
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

i havent checked the script but on guess of what i know there must be a area to set the timezone and most lightly like this

Code: Select all

set timezone "timezone"
 

and check if both " " are there and not just one :D
i'll look at the script in a bit ;)
ComputerTech
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Not sure what this 2 lines

Code: Select all

regsub {\.000Z} $pubiso "" pubiso
regsub -all {Z} $pubiso "" pubiso
are supposed to do since don't have the code running and can only guess..

Anyway, replacing the:

Code: Select all

set pubtime [clock format [clock scan $pubiso]]
with:

Code: Select all

set pubtime [clock format [clock scan [string map [list "T" " " "Z" ""] $pubiso]]]
should do the trick.
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

excellent that seems to do it caesar tnx for the swift reply and fix
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

in all fairness i must comment that m00nie seems to already have fixed that bug in his latest release as i didnt check his latest release i just did
just wanted to say this but none the less thx caesar for providing a quick fix
User avatar
m4s
Halfop
Posts: 97
Joined: Mon Jan 30, 2017 3:24 pm

Post by m4s »

Oh, I did not check either. :roll:
Thanks to everyone!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I looked on the website at comments section and saw an output from YouTube's API:

Code: Select all

[14:53:42] m00nie::youtube::getinfo IDS are {snippet {publishedAt 2015-08-10T22:24:25.000Z title {IFC's VICE Parody: 'DRONEZ' (Full Episode)} channelTitle VICE} contentDetails {duration PT22M52S} statistics {viewCount 36205}}
and notice the 'publishedAt' is 2015-08-10T22:24:25.000Z

Those two lines I was puzzled about:

Code: Select all

regsub {\.000Z} $pubiso "" pubiso
regsub -all {Z} $pubiso "" pubiso 
do this:

Code: Select all

% set pubiso "2015-08-10T22:24:25.000Z"
2015-08-10T22:24:25.000Z
% regsub {\.000Z} $pubiso "" pubiso
1
% regsub -all {Z} $pubiso "" pubiso
0
% puts $pubiso
2015-08-10T22:24:25
% clock format [clock scan $pubiso]
Tue Aug 11 08:24:25 EEST 2015
From here I notice two things:

1. The presence of the T in the $pubiso
2. The 'clock format' output is WRONG because the '2015-08-10 22:24:25' (notice that i just removed the T) becomes 'Tue Aug 11 08:24:25 EEST 2015' after 'clock format'

I would just ditch those 'regsub' lines and just use 'string map' instead:

Code: Select all

set pubiso [string map {"T" " " ".000Z" ""} $pubiso]
while keeping the original:

Code: Select all

set pubtime [clock format [clock scan $pubiso]]
and thus ignoring my previous fix. The output is clean as it should be:

Code: Select all

% set pubiso "2015-08-10T22:24:25.000Z"
2015-08-10T22:24:25.000Z
% set pubiso [string map {"T" " " ".000Z" ""} $pubiso]
2015-08-10 22:24:25
so this means that after 'clock format' the formatted date is correct:

Code: Select all

% clock format [clock scan $pubiso]
Mon Aug 10 22:24:25 EEST 2015
Once the game is over, the king and the pawn go back in the same box.
m
m00nie
Voice
Posts: 14
Joined: Sat Mar 28, 2020 2:02 pm

Post by m00nie »

Hi Caesar ☺️

Thanks for the spot on the date being red incorrectly.ive updated the script to sort this along with your suggestion of the string maps (which I've never used before now so nice to learn something cleaner 😁)
The change that broke the script though is the API now randomly(?) seems to append a single Z rather than the expected .000Z we got before (something to do with recommend way to pass time in C+)
v2.4 should hopefully fix both probs
Cheers

m00nie
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

hey there m00nie i loaded your youtube tcl 2.4 in tcl pastebin and it returned a few errors
Line 36: ERROR: Unknown variable "m00nie::youtube::regex"
Line 40: ERROR: Unknown variable "m00nie::youtube::key"
Line 79: ERROR: Unknown variable "m00nie::youtube::user_throt"
Line 80: ERROR: Unknown variable "m00nie::youtube::chan_throt"
Line 81: ERROR: Unknown variable "m00nie::youtube::link_throt"
Line 89: NOTICE: Found constant "rawpage" which is also a variable.
Line 93: WARNING: Unknown command "json::json2dict"
Line 105: ERROR: Unknown variable "m00nie::youtube::key"
b
bugme
Voice
Posts: 6
Joined: Fri Jan 13, 2017 9:49 am

Post by bugme »

I can see some problems with the code page with non-English names.

example: https://www.youtube.com/watch?v=YcaWvpYt7oI

m00nie-youtube.2.4.tcl
result:

Code: Select all

GJ8Þó ,40q Á‹_n -Mè-��#GJ8Þó #á
expected result:

Code: Select all

GJ8マン 第40話 『私、見たの! -前編-』 #GJ8マン #郡上八幡 #さくらももこ
debian:bullsey
eggdrop 1.8.4
tcl 8.6.9
tcl-tls 1.7.21
tclcurl 7.22.0+hg20160822-2
tcllib 1.20
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

works fine for me with any lang
m
m00nie
Voice
Posts: 14
Joined: Sat Mar 28, 2020 2:02 pm

Post by m00nie »

Hi bugme

I think you might need to check your bot is compiled with UTF-8 support or what the default encoding is on your OS. I had to recompile some of my older hosted bots to get UTF-8 working properly
Cheers

m00nie
b
bugme
Voice
Posts: 6
Joined: Fri Jan 13, 2017 9:49 am

Post by bugme »

m00nie wrote:Hi bugme
default encoding is on your OS.
m00nie
Yes. You're right
I use docker container. I forgot to check locale

Code: Select all

locale
LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
Updated Dockerfile. Problem solved. Thanks for the tip


p.s.
It is strange that this script does not have this problem, even with non-update locale http://forum.egghelp.org/viewtopic.php?p=108565#108565
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

for some reason on a particular box i cant get m00nies YT tcl to output in utf-8
while : .tcl encoding system
shows : Tcl: utf-8
im puzzled what else to try

eggdrop v1.8.4
Tcl library: /usr/share/tcltk/tcl8.6
Tcl version: 8.6.10 (header version 8.6.10)
Tcl is threaded
TLS support is enabled
TLS library: OpenSSL 1.1.1f 31 Mar 2020





for locale this is what we have:

LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
Post Reply