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

feature: direct file import via "Browse & Access" #9

Open
philips opened this issue Mar 25, 2024 · 3 comments
Open

feature: direct file import via "Browse & Access" #9

philips opened this issue Mar 25, 2024 · 3 comments

Comments

@philips
Copy link
Owner

philips commented Mar 25, 2024

It would be nice to skip the cloud syncing and whatever and just directly import files via Browse & Access, I think.

The URL structure for the individual files is reasonable e.g. http://192.168.1.100:8089/Note/test.note however the browsing index seems to be a messy HTML thingie that would need to be parsed.

Example table:

<div id="table-item" class="table-item" style="width: 100%; height: 223px; overflow: auto;">
                <table class="table item">
                    <colgroup>
                        <col style="width: 60%">
                        <col style="width: 20%">
                        <col style="width: 20%">
                    </colgroup>
                    <!--                <tbody> 标签用于组合 HTML 表格的主体内容。-->
                    <tbody id="item-container" style="width:100%;height: 100%;">

                    <tr>

<td rowspan="1" colspan="1"><div class="cell el-tooltip name"><a class="file-name" href="/Note/20240324_232111.doc"><span class="file-name" title="20240324_232111.doc">20240324_232111.doc</span></a></div></td><td rowspan="1" colspan="1"><div class="cell el-tooltip">9.50 KB</div></td>

<td rowspan="1" colspan="1"><div class="cell el-tooltip">2024-03-24 23:21</div></td></tr><tr><td rowspan="1" colspan="1"><div class="cell el-tooltip name"><a class="file-name" href="/Note/20240324_232120.note"><span class="file-name" title="20240324_232120.note">20240324_232120.note</span></a></div></td>

<td rowspan="1" colspan="1"><div class="cell el-tooltip">201.24 KB</div></td><td rowspan="1" colspan="1"><div class="cell el-tooltip">2024-03-24 23:22</div></td></tr><tr><td rowspan="1" colspan="1"><div class="cell el-tooltip name"><a class="file-name" href="/Note/journal.note"><span class="file-name" title="journal.note">journal.note</span></a></div></td>

<td rowspan="1" colspan="1"><div class="cell el-tooltip">4.71 MB</div></td><td rowspan="1" colspan="1"><div class="cell el-tooltip">2024-03-24 23:19</div></td></tr></tbody>
                </table>
            </div>

Guess at a simple scraper:

function extractTableUrls(): string[] {
  const table = document.getElementById('item-container') as HTMLTableElement;
  const urls: string[] = [];

  if (!table) {
    return urls; // Handle case where table element not found
  }

  const rows = table.querySelectorAll('tr');
  for (const row of rows) {
    const anchor = row.querySelector('a[href]');
    if (anchor) {
      urls.push(anchor.href);
    }
  }

  return urls;
}

// Example usage
const extractedUrls = extractTableUrls();
console.log(extractedUrls); // This will print an array of extracted URLs
@mmujynya
Copy link

mmujynya commented Jun 1, 2024

This is 2 months old, so not sure if still an open issue. I am accessing files through port 8089 in a personal project and would be happy to share code.

@philips
Copy link
Owner Author

philips commented Jun 1, 2024

@mmujynya If you have typescript code for pulling files that would be great for you to share.

@mmujynya
Copy link

mmujynya commented Jun 1, 2024

Unfortunately in python only. But see gpt's translation, if it may help (I have absolutely no idea if this is correct): https://chatgpt.com/share/e9a3df99-149b-4745-b0ab-fbb3ce043c9b

A snippet of my code in Python https://drive.google.com/drive/folders/1YdiJvijfiqHzSpswCmJqAqki92H5jv89

I haven't looked yet at Obsidian, but planning to take advantage of that tool in the near future. Thank you for your contributions to the SN community!

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