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

TypeError: Cannot read property 'items' of undefined #12

Open
VladimirCores opened this issue Aug 30, 2021 · 4 comments
Open

TypeError: Cannot read property 'items' of undefined #12

VladimirCores opened this issue Aug 30, 2021 · 4 comments

Comments

@VladimirCores
Copy link

Posting only text without attachments:

0|npm  | TypeError: Cannot read property 'items' of undefined
0|npm  |     at sendVideo (/home/***/node_modules/vk-to-telegram/lib/sender.js:85:90)
0|npm  |     at async mediaPoster (/home/***/node_modules/vk-to-telegram/lib/forwarder.js:178:29)
0|npm  |     at async Forwarder.send (/home/***/node_modules/vk-to-telegram/index.js:177:15)
0|npm  |     at async exports.handleSocialContentVKNewPost (/home/***/index.js:30:20)
0|npm  | Unhandled rejection

Screen Capture_select-area_20210830165541

@VladimirCores
Copy link
Author

Looks like something wrong with video, but I can't understand why, the attachment looks:

{
        "type": "video",
        "video": {
          "access_key": "fde38d9e09f71df447",
          "can_comment": 1,
          "can_edit": 1,
          "can_like": 1,
          "can_repost": 1,
          "can_subscribe": 1,
          "can_add_to_faves": 1,
          "can_add": 1,
          "can_attach_link": 1,
          "comments": 0,
          "date": 1626588043,
          "description": "Original video: https://vimeo.com/385536746",
          "duration": 412,
          "image": [
            {
              "height": 96,
              "url": "https://i.mycdn.me/getVideoPreview?id=1498471074326&idx=5&type=39&tkn=lDnXGsFE4Nyl-TQlYG1g_weejjQ&fn=vid_s",
              "width": 130,
              "with_padding": 1
            },
            {
              "height": 120,
              "url": "https://i.mycdn.me/getVideoPreview?id=1498471074326&idx=5&type=39&tkn=lDnXGsFE4Nyl-TQlYG1g_weejjQ&fn=vid_m",
              "width": 160,
              "with_padding": 1
            },
            {
              "height": 240,
              "url": "https://i.mycdn.me/getVideoPreview?id=1498471074326&idx=5&type=39&tkn=lDnXGsFE4Nyl-TQlYG1g_weejjQ&fn=vid_l",
              "width": 320,
              "with_padding": 1
            },
            {
              "height": 450,
              "url": "https://i.mycdn.me/getVideoPreview?id=1498471074326&idx=5&type=39&tkn=lDnXGsFE4Nyl-TQlYG1g_weejjQ&fn=vid_x",
              "width": 800,
              "with_padding": 1
            },
            {
              "height": 720,
              "url": "https://i.mycdn.me/getVideoPreview?id=1498471074326&idx=5&type=39&tkn=lDnXGsFE4Nyl-TQlYG1g_weejjQ&fn=vid_w",
              "width": 1280
            },
            {
              "height": 180,
              "url": "https://i.mycdn.me/getVideoPreview?id=1498471074326&idx=5&type=39&tkn=lDnXGsFE4Nyl-TQlYG1g_weejjQ&fn=vid_t",
              "width": 320
            },
            {
              "height": 405,
              "url": "https://i.mycdn.me/getVideoPreview?id=1498471074326&idx=5&type=39&tkn=lDnXGsFE4Nyl-TQlYG1g_weejjQ&fn=vid_u",
              "width": 720
            }
          ],
          "first_frame": [
            {
              "height": 405,
              "url": "https://i.mycdn.me/getVideoPreview?id=1498471074326&idx=0&type=32&tkn=Xvq_oPiAUHK2KiAFLOBddlLcRmc",
              "width": 720
            },
            {
              "height": 270,
              "url": "https://i.mycdn.me/getVideoPreview?id=1498471074326&idx=0&type=33&tkn=GADfJtWEzfCYjV1--IAbZRhIis0",
              "width": 480
            },
            {
              "height": 135,
              "url": "https://i.mycdn.me/getVideoPreview?id=1498471074326&idx=0&type=34&tkn=a44cx32MATBSx-l7Wx-yUGDpEts",
              "width": 240
            },
            {
              "height": 72,
              "url": "https://i.mycdn.me/getVideoPreview?id=1498471074326&idx=0&type=35&tkn=3SJ8xSoqOvCPLsYOZUQKW_6zMOA",
              "width": 128
            },
            {
              "height": 720,
              "url": "https://i.mycdn.me/getVideoPreview?id=1498471074326&idx=0&type=37&tkn=e2t6DJWwDiC3oe8lbdkI8CTDebM",
              "width": 1280
            },
            {
              "height": 540,
              "url": "https://i.mycdn.me/getVideoPreview?id=1498471074326&idx=0&type=38&tkn=mtdEnFuYxLe93bkefvHJGHtu0U4",
              "width": 960
            },
            {
              "height": 720,
              "url": "https://i.mycdn.me/getVideoPreview?id=1498471074326&idx=0&type=39&tkn=5ReDlGLHxZIVYnQj0_lqxNkrxZA",
              "width": 1280
            }
          ],
          "width": 1920,
          "height": 1080,
          "id": 456240206,
          "owner_id": -48406435,
          "title": "Empyreum",
          "is_favorite": false,
          "track_code": "video_679077a7_hq51_xXzXl6jQ-yW0pCFNBlC_OBqUZJZWbIrVnBSYrIMaDT8lfOehGNDdpaf3Qm5FU5w7euMycOCKc",
          "type": "video",
          "views": 61
        }
      },

And when I try to get it from VK API documentation, empty array returned:
Screen Capture_select-area_20210830173616
Video exists for sure: https://vk.com/invisart?z=video-48406435_456240206

@VladimirCores
Copy link
Author

Ok looks like I fixed the problem on line 85:

const apivideo = (await vkapi.video.get(`${video.owner_id}_${video.id}`)).response?.items[0]

@VladimirCores
Copy link
Author

However the result is not exactly what I'm expecting, the content looks like individual items not the one post:
Screen Capture_select-area_20210830175326
Is there any way of how to combine them all into one?

@ejnshtein
Copy link
Owner

@VladimirCores Dunno, I need to totally refactor this shit 😅

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

No branches or pull requests

2 participants