SkPy icon indicating copy to clipboard operation
SkPy copied to clipboard

No preview for a link in Skype

Open eirenik0 opened this issue 6 years ago • 9 comments

No preview for a link in Skype. When I sent a similar link through the Skype app there is a preview, but not with skpy.

I've found that I can fetch link manually by call getUrlMeta but I have no idea where to past that response.

UPD: Preview does work with old version of Skype for Web, but not in new one and other versions.

Account type

Live account

Steps to reproduce

    from skpy import Skype
    cli = Skype('username', 'password')
    chat = cli.chats.chat('chat_id')
    # Clickable link but no preview
    chat.sendMsg('<a href="https://github.com">Some link</a>', rich=True)
    # Similar as above
    chat.sendMsg('<a href="https://github.com">https://stackoverflow.com</a>', rich=True)

Result or traceback

Just regular text without link preview.

eirenik0 avatar Feb 27 '19 12:02 eirenik0

Weird, one would expect that to be done purely by the client-side receiver (getUrlMeta calls the endpoint Skype for Web uses as a receiving client).

Guess that means the sending client is now expected to include some extra markup on links? What does a link in the raw message look like when sent from the new Skype for Web?

Terrance avatar Feb 27 '19 19:02 Terrance

Here is are the HTML of the row: image

<div role="region" tabindex="-1"
     aria-label="AllatRa отправляет веб-сайт Совместный лайф. Почему сознание не дает записывать влоги?, Какие отговорки придумывает сознание, чтобы не записывать влоги, в которых  человек обличает системы и вскрывает ее основный шаблоны? Почему системе так не выгодно чтобы проливался свет на ее тайно... в 14:19."
     style="position: absolute; display: flex; flex-direction: column; flex-grow: 0; flex-shrink: 0; overflow: visible; align-items: stretch; width: 1060px; transform: translateY(3458px);">
    <div role="none"
         style="position: relative; display: flex; flex-direction: column; flex-grow: 0; flex-shrink: 0; overflow: hidden; align-items: stretch;">
        <div role="none"
             style="position: relative; display: flex; flex-direction: row; flex-grow: 0; flex-shrink: 0; overflow: hidden; align-items: stretch; align-self: stretch; padding-top: 1px; padding-right: 50px;">
            <div role="none"
                 style="position: relative; display: flex; flex-direction: row; flex-grow: 1; flex-shrink: 1; overflow: hidden; align-items: stretch; justify-content: flex-end; padding-left: 206px; transform: translateX(0px);">
                <div role="none"
                     style="position: relative; display: flex; flex-direction: column; flex-grow: 0; flex-shrink: 0; overflow: hidden; align-items: flex-end; opacity: 1;">
                    <button role="button" title="Переслать" aria-label="Переслать" tabindex="-1"
                            style="position: relative; display: flex; flex-direction: column; flex-grow: 0; flex-shrink: 0; overflow: hidden; align-items: center; justify-content: flex-start; background-color: transparent; border-color: transparent; text-align: left; border-width: 0px; padding: 2px 8px 4px 20px; width: 44px; height: 39px; cursor: pointer; border-style: solid;">
                        <div aria-hidden="true" data-text-as-pseudo-element=""
                             style="position: relative; display: inline; flex-grow: 0; flex-shrink: 0; overflow: visible; white-space: pre-wrap; overflow-wrap: break-word; height: 16px; font-size: 16px; color: rgb(138, 141, 145); background-color: rgba(0, 0, 0, 0); font-family: SkypeAssets-Light; padding: 0px; flex-direction: row; align-self: center; align-items: center; justify-content: center; cursor: inherit;"></div>
                    </button>
                </div>
                <div role="none"
                     style="position: relative; display: flex; flex-direction: column; flex-grow: 0; flex-shrink: 1; overflow: hidden; align-items: stretch; background-color: rgba(0, 0, 0, 0); min-height: 30px;">
                    <div role="none"
                         style="position: relative; display: flex; flex-direction: column; flex-grow: 0; flex-shrink: 0; overflow: hidden; align-items: stretch;">
                        <div role="none"
                             style="position: relative; display: flex; flex-direction: column; flex-grow: 0; flex-shrink: 1; overflow: hidden; align-items: stretch; border-radius: 10px 0px 0px 10px; transform: translateX(0px);">
                            <div role="none"
                                 style="position: relative; display: flex; flex-direction: column; flex-grow: 1; flex-shrink: 1; overflow: hidden; align-items: stretch; --sheep-it:1.84135e+18;">
                                <div role="none"
                                     style="position: relative; display: flex; flex-direction: column; flex-grow: 0; flex-shrink: 0; overflow: hidden; align-items: stretch;">
                                    <div role="none"
                                         style="position: relative; display: flex; flex-direction: column; flex-grow: 1; flex-shrink: 1; overflow: hidden; align-items: stretch; align-self: stretch;">
                                        <button role="button"
                                                title="https://allatra.tv/video/sovmestnyj-life-pochemu-soznanie-ne-daet-zapisyvat-vlogi"
                                                aria-label="AllatRa отправляет веб-сайт Совместный лайф. Почему сознание не дает записывать влоги?, Какие отговорки придумывает сознание, чтобы не записывать влоги, в которых  человек обличает системы и вскрывает ее основный шаблоны? Почему системе так не выгодно чтобы проливался свет на ее тайно... в 14:19."
                                                aria-disabled="false" tabindex="-1"
                                                style="position: relative; display: flex; flex-direction: column; flex-grow: 0; flex-shrink: 0; overflow: hidden; align-items: stretch; justify-content: center; background-color: rgb(241, 241, 244); border-color: rgba(0, 0, 0, 0); text-align: left; border-width: 0px; width: 300px; border-radius: 10px 0px 0px 10px; padding: 0px; cursor: pointer;">
                                            <div role="none"
                                                 style="position: relative; display: flex; flex-direction: column; flex-grow: 0; flex-shrink: 0; overflow: hidden; align-items: stretch; border-width: 0px; border-color: rgba(0, 0, 0, 0);">
                                                <div role="none"
                                                     style="position: relative; display: flex; flex-direction: column; flex-grow: 0; flex-shrink: 0; overflow: hidden; align-items: stretch; border-width: 0px; border-color: rgba(0, 0, 0, 0); width: 300px; height: 150px; background-color: rgb(213, 217, 222); border-top-left-radius: 10px; border-top-right-radius: 10px;">
                                                    <div style="position: relative; overflow: visible; background-color: transparent; flex-grow: 0; flex-shrink: 0; width: 300px; height: 150px; border-top-left-radius: 10px; border-top-right-radius: 10px; background-position: center center; background-repeat: no-repeat; background-image: url(&quot;https://weu1-urlp.secure.skypeassets.com/img1/59e74f0c-678f-422c-81ec-771a9d1fbf2c.jpeg&quot;); background-size: cover; border-style: none; display: flex;"></div>
                                                </div>
                                                <div style="position: relative; display: inline; flex-grow: 0; flex-shrink: 0; overflow: hidden; white-space: pre-wrap; overflow-wrap: break-word; font-size: 18px; color: rgb(37, 36, 35); font-family: &quot;SF Bold&quot;, &quot;Segoe System UI Bold&quot;, &quot;Segoe UI Bold&quot;, sans-serif; font-weight: 400; margin-top: 10px; line-height: 22px; padding-left: 10px; padding-right: 10px; max-height: 44px; cursor: inherit;">
                                                    Совместный лайф. Почему сознание не дает записывать влоги?
                                                </div>
                                                <div data-text-as-pseudo-element="Какие отговорки придумывает сознание, чтобы не записывать влоги, в которых  человек обличает системы и вскрывает ее основный шаблоны? Почему системе так не выгодно чтобы проливался свет на ее тайно..."
                                                     style="position: relative; display: inline; flex-grow: 0; flex-shrink: 0; overflow: hidden; white-space: pre-wrap; overflow-wrap: break-word; font-size: 12px; color: rgb(138, 141, 145); font-family: &quot;SF Regular&quot;, &quot;Segoe System UI Regular&quot;, &quot;Segoe UI Regular&quot;, sans-serif; font-weight: 400; margin-top: 4px; padding-left: 10px; padding-right: 10px; line-height: 16px; max-height: 32px; cursor: inherit;"></div>
                                                <div role="none"
                                                     style="position: relative; display: flex; flex-direction: row; flex-grow: 0; flex-shrink: 0; overflow: hidden; align-items: flex-start; margin-top: 7px; margin-bottom: 12px; padding-left: 12px; padding-right: 12px;">
                                                    <div role="none"
                                                         style="position: relative; display: flex; flex-direction: column; flex-grow: 0; flex-shrink: 0; overflow: hidden; align-items: stretch; height: 16px; width: 16px;">
                                                        <div style="position: relative; overflow: visible; background-color: transparent; flex-grow: 0; flex-shrink: 0; height: 16px; width: 16px; background-position: center center; background-repeat: no-repeat; background-image: url(&quot;https://weu1-urlp.secure.skypeassets.com/img1/b3739ca9-e269-45b5-ab26-0104d8c0ea59.png&quot;); background-size: cover; border-style: none; display: flex;"></div>
                                                    </div>
                                                    <div style="position: relative; display: inline; flex-grow: 1; flex-shrink: 1; overflow: hidden; white-space: pre; text-overflow: ellipsis; font-size: 12px; color: rgb(138, 141, 145); font-family: &quot;SF Regular&quot;, &quot;Segoe System UI Regular&quot;, &quot;Segoe UI Regular&quot;, sans-serif; font-weight: 400; margin-left: 4px; cursor: inherit;">
                                                        https://allatra.tv
                                                    </div>
                                                </div>
                                            </div>
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

eirenik0 avatar Feb 28 '19 12:02 eirenik0

I mean the actual message content, not Skype for Web's rendering of it.

Send a message from new Skype for Web, receive it in SkPy, and check SkypeMsg.content.

Terrance avatar Feb 28 '19 14:02 Terrance

Here is a msg content of several msgs:

'\nОсознания людей после фильма СОЗНАНИЕ И ЛИЧНОСТЬ\n#allatra_tv\n\n<a href="https://allatra.tv/video/sovmestnyj-life-pochemu-soznanie-ne-daet-zapisyvat-vlogi">Совместный лайф. Почему сознание не дает записыват
ь влоги?</a>'
'<a href="h
ttps://allatra.tv/video/sovmestnyj-life-pochemu-soznanie-ne-daet-zapisyvat-vlogi">https://allatra.tv/video/sovmestnyj-life-pochemu-soznanie-ne-daet-zapisyvat-vlogi</a>'

You've written that class should be SkypeMsg but I've got SkypeTextMsg. Not sure if this addition is relevant :)

If Cyrillic is bothering you, I could make a post in English :)

eirenik0 avatar Mar 01 '19 10:03 eirenik0

No obvious additional markup then. 😐 If you try sending a message from SkPy and from new Skype for Web, there may be some clues if you compare the raw attributes. That holds the whole server response, so there will be a lot of noise, but maybe it has to declare a link for expanding in there somewhere.

For SkPy, you need to retrieve the message from the server rather than looking at the one you just sent. Easiest way is to send the same link via SkPy and S4W, then retrieve both using SkypeChat.getMsgs().


You've written that class should be SkypeMsg but I've got SkypeTextMsg.

SkypeMsg provides the content attribute; SkypeTextMsg is just a subclass for text-based messages.

Terrance avatar Mar 01 '19 13:03 Terrance

Interesting that links that sent from old S4W have no preview in a new one. The content text of SkypeMsg is similar. Where I should looking for text of the message? Should it be in payload? I'm see there only something like this for old skype:

+
IJS_default_source©$ec525caa-092f-592d-eceb-09c9077cb879ÑäÍ×þ§ZË
)$df2227f1-b2d1-3f5d-ad8d-f8140926c336qâÍ×þ§Z©customÉkpi_inapp_activity_startÍ
		+EventInfo.SourceJS_default_sourceEventInfo.InitId$be61185f-c9d6-ec24-ae0e-804700cea14eEventInfo.Sequence148EventInfo.Namekpi_inapp_activity_startEventInfo.Time2019-03-02T19:39:16.209ZEventInfo.SdkVersionACT-Web-JS-2.7.1AppInfo.Languageen-usUserInfo.LanguageruUserInfo.TimeZone+02:00DeviceInfo.BrowserNameFirefoxDeviceInfo.BrowserVersion65.0DeviceInfo.OsNameWindowsDeviceInfo.OsVersion10
DeviceInfo.Id$985803d6-2b91-f076-0459-74b54d62ff14AppInfo.Version1.125.43Entry_PointForegroundedForeground_Start_Time
1551555556209	GuestFlowfalse
session_id$5b774677-f963-43bb-0960-48286c985945tab_session_id$834212d8-4fb6-4fef-2041-5f29b7eeb7f9user_agent_nameFirefoxuser_agent_version65
user_agent_OSWindowsuser_agent_OS_version10device_type1screen_width1536
screen_height864cid_hostPropertySkypePortal
cid_sessionId$49f0f026-e6b1-4d69-0cb5-58865a952fbc	cid_tabId$49f0f026-e6b1-4d69-0cb5-58865a952fbcapi_key	skype.comlocaleen-us
ui_version908/1.125.0.43//skype.comversion1.125.43property	skype.comClient_NameWebetag."Sqrldr0M7kW/C41uoqfJh8QgfF1YpIALtJBjY="cfg_ids¡P-R-29040-1-11,P-R-27083-1-8,P-R-23647-1-5,P-R-22489-1-6,P-R-22368-1-6,P-R-22219-1-8,P-R-21836-1-10,P-R-21193-2-15,P-R-21022-1-6,P-R-20676-1-12,P-D-5056-9157-474browser_notifications_enabledfalse	signed_in1Skype_InitiatingUser_Username
live:***** technical_account1
current_themedefaultÍ	
user_id0Pi
live:*****

eirenik0 avatar Mar 02 '19 20:03 eirenik0

I'm not sure what that blob is, where did you get it?

I just tried sending from old and new S4Ws, the payload as seen from old S4W (and therefore from SkPy) appears to be the same:

>>> pprint.pprint(sk.chats['8:fred.2'].getMsgs()[0].raw)
{'clientmessageid': '1551607385077',
 'composetime': '2019-03-03T10:05:21.259Z',
 'content': '<a href="https://medium.com/s/story/why-i-stopped-arguing-politics-on-social-media-f695344d3e3">'
            'https://medium.com/s/story/why-i-stopped-arguing-politics-on-social-media-f695344d3e3</a>',
 'conversationLink': 'https://ch1-client-s.gateway.messenger.live.com/v1/users/ME/conversations/8:fred.2',
 'conversationid': '8:fred.2',
 'from': 'https://ch1-client-s.gateway.messenger.live.com/v1/users/ME/contacts/8:fred.2',
 'id': '1551607521743',
 'messagetype': 'RichText',
 'originalarrivaltime': '2019-03-03T10:05:21.259Z',
 'type': 'Message',
 'version': '1551607521743'}

Given the sending model is completely different in new S4W (sent via an open websocket in a different format), I'm not sure if this is actually fixable using the old endpoint. The fact that links sent from old S4W don't expand either at least confirms it's not a library issue, but one with the API we're using.

Terrance avatar Mar 03 '19 10:03 Terrance

How big this task is? Maybe I could implement it

eirenik0 avatar Mar 03 '19 10:03 eirenik0

See notes in #105.

Terrance avatar Mar 03 '19 11:03 Terrance